From: Florian Weimer Date: Tue, 14 Aug 2018 08:51:07 +0000 (+0200) Subject: nscd: Deallocate existing user names in file parser X-Git-Tag: glibc-2.29~535 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d7acfac3ebf266dcbc82d0d6cc576f626953a03;p=thirdparty%2Fglibc.git 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). --- diff --git a/ChangeLog b/ChangeLog index 5de199ecbaf..bf3c1338b85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-08-14 Florian Weimer + + * nscd/nscd_conf.c (nscd_parse_file): Deallocate old storage for + server_user, stat_user. + 2018-08-13 Joseph Myers * sysdeps/unix/sysv/linux/syscall-names.list: Update kernel diff --git a/nscd/nscd_conf.c b/nscd/nscd_conf.c index 265a02434dd..7293b795b6b 100644 --- a/nscd/nscd_conf.c +++ b/nscd/nscd_conf.c @@ -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);