]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Plug econf memory leaks
authorTobias Stoeckmann <tobias@stoeckmann.org>
Thu, 18 May 2023 15:25:35 +0000 (17:25 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 19 May 2023 13:02:24 +0000 (08:02 -0500)
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 <tobias@stoeckmann.org>
lib/getdef.c
src/chsh.c

index a2a7e484cd78247f513bcb2da4bd1b8da8c693dd..763d847ab492785a141543a69c508d33e8d32776 100644 (file)
@@ -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);
index d6eca6e36df40c91c9cdf80ac638a1a0ef939491..87aa4cb7468dbff4e910e8e9d26a869c9204d0f5 100644 (file)
@@ -180,6 +180,7 @@ static bool shell_is_listed (const char *sh)
                        break;
                }
        }
+       econf_free (keys);
        econf_free (key_file);
 
        return found;