From 8175b1532e4bb1951264e8a6ee5f484137e5306c Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Thu, 18 May 2023 17:25:35 +0200 Subject: [PATCH] Plug econf memory leaks You can see the memory leaks with address sanitizer if shadow is compiled with `--enable-vendordir=/usr/etc`. How to reproduce: 1. Prepare a custom shell file as root ``` mkdir -p /etc/shells.d echo /bin/myshell > /etc/shells.d/custom ``` 2. Run chsh as regular user ``` chsh ``` Signed-off-by: Tobias Stoeckmann --- lib/getdef.c | 2 ++ src/chsh.c | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/getdef.c b/lib/getdef.c index a2a7e484..763d847a 100644 --- a/lib/getdef.c +++ b/lib/getdef.c @@ -522,6 +522,8 @@ static void def_load (void) * syslog. The tools will just use their default values. */ (void)putdef_str (keys[i], value); + + free(value); } econf_free (keys); diff --git a/src/chsh.c b/src/chsh.c index d6eca6e3..87aa4cb7 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -180,6 +180,7 @@ static bool shell_is_listed (const char *sh) break; } } + econf_free (keys); econf_free (key_file); return found;