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 <tobias@stoeckmann.org>
This commit is contained in:
Tobias Stoeckmann 2023-05-18 17:25:35 +02:00 committed by Serge Hallyn
parent 7321ceaf69
commit 8175b1532e
2 changed files with 3 additions and 0 deletions

View 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);

View File

@ -180,6 +180,7 @@ static bool shell_is_listed (const char *sh)
break;
}
}
econf_free (keys);
econf_free (key_file);
return found;