From: Tobias Stoeckmann Date: Thu, 18 May 2023 15:25:35 +0000 (+0200) Subject: Plug econf memory leaks X-Git-Tag: 4.14.0-rc1~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8175b1532e4bb1951264e8a6ee5f484137e5306c;p=thirdparty%2Fshadow.git 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 --- diff --git a/lib/getdef.c b/lib/getdef.c index a2a7e484c..763d847ab 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 d6eca6e36..87aa4cb74 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;