nscd: Deallocate existing user names in file parser

This avoids a theoretical memory leak (theoretical because it depends on
multiple server-user/stat-user directives in the configuration file).
This commit is contained in:
Florian Weimer 2018-08-14 10:51:07 +02:00
parent 17b26500f9
commit 2d7acfac3e
2 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2018-08-14 Florian Weimer <fweimer@redhat.com>
* nscd/nscd_conf.c (nscd_parse_file): Deallocate old storage for
server_user, stat_user.
2018-08-13 Joseph Myers <joseph@codesourcery.com>
* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel

View File

@ -190,7 +190,10 @@ nscd_parse_file (const char *fname, struct database_dyn dbs[lastdb])
if (!arg1)
error (0, 0, _("Must specify user name for server-user option"));
else
server_user = xstrdup (arg1);
{
free ((char *) server_user);
server_user = xstrdup (arg1);
}
}
else if (strcmp (entry, "stat-user") == 0)
{
@ -198,6 +201,7 @@ nscd_parse_file (const char *fname, struct database_dyn dbs[lastdb])
error (0, 0, _("Must specify user name for stat-user option"));
else
{
free ((char *) stat_user);
stat_user = xstrdup (arg1);
struct passwd *pw = getpwnam (stat_user);