50f89d
commit bfcfa22589f2b4277a65e60c6b736b6bbfbd87d0
50f89d
Author: Florian Weimer <fweimer@redhat.com>
50f89d
Date:   Tue Aug 14 10:51:07 2018 +0200
50f89d
50f89d
    nscd: Deallocate existing user names in file parser
50f89d
    
50f89d
    This avoids a theoretical memory leak (theoretical because it depends on
50f89d
    multiple server-user/stat-user directives in the configuration file).
50f89d
    
50f89d
    (cherry picked from commit 2d7acfac3ebf266dcbc82d0d6cc576f626953a03)
50f89d
50f89d
diff --git a/nscd/nscd_conf.c b/nscd/nscd_conf.c
50f89d
index 265a02434dd26c29..7293b795b6bcf71e 100644
50f89d
--- a/nscd/nscd_conf.c
50f89d
+++ b/nscd/nscd_conf.c
50f89d
@@ -190,7 +190,10 @@ nscd_parse_file (const char *fname, struct database_dyn dbs[lastdb])
50f89d
 	  if (!arg1)
50f89d
 	    error (0, 0, _("Must specify user name for server-user option"));
50f89d
 	  else
50f89d
-	    server_user = xstrdup (arg1);
50f89d
+	    {
50f89d
+	      free ((char *) server_user);
50f89d
+	      server_user = xstrdup (arg1);
50f89d
+	    }
50f89d
 	}
50f89d
       else if (strcmp (entry, "stat-user") == 0)
50f89d
 	{
50f89d
@@ -198,6 +201,7 @@ nscd_parse_file (const char *fname, struct database_dyn dbs[lastdb])
50f89d
 	    error (0, 0, _("Must specify user name for stat-user option"));
50f89d
 	  else
50f89d
 	    {
50f89d
+	      free ((char *) stat_user);
50f89d
 	      stat_user = xstrdup (arg1);
50f89d
 
50f89d
 	      struct passwd *pw = getpwnam (stat_user);