]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nscd: Deallocate existing user names in file parser
authorFlorian Weimer <fweimer@redhat.com>
Tue, 14 Aug 2018 08:51:07 +0000 (10:51 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 14 Aug 2018 08:51:07 +0000 (10:51 +0200)
This avoids a theoretical memory leak (theoretical because it depends on
multiple server-user/stat-user directives in the configuration file).

ChangeLog
nscd/nscd_conf.c

index 5de199ecbafbec0ad672496ec54053739c68e8ab..bf3c1338b855b2dda98bdc4517059cf00858f04f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 265a02434dd26c290cce4378991e693d47ab9a04..7293b795b6bcf71e2080bab0d078f776471ed5ae 100644 (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);