about summary refs log tree commit diff
path: root/nscd/nscd_conf.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2018-08-14 10:51:07 +0200
committerFlorian Weimer <fweimer@redhat.com>2018-08-14 10:51:07 +0200
commit2d7acfac3ebf266dcbc82d0d6cc576f626953a03 (patch)
tree5b458e0377e7c221ccfc9e97ae5f6286d572fc1c /nscd/nscd_conf.c
parent17b26500f9bb926d85e86821d014f7c1bb88043c (diff)
downloadglibc-2d7acfac3ebf266dcbc82d0d6cc576f626953a03.tar.gz
glibc-2d7acfac3ebf266dcbc82d0d6cc576f626953a03.tar.xz
glibc-2d7acfac3ebf266dcbc82d0d6cc576f626953a03.zip
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).
Diffstat (limited to 'nscd/nscd_conf.c')
-rw-r--r--nscd/nscd_conf.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/nscd/nscd_conf.c b/nscd/nscd_conf.c
index 265a02434d..7293b795b6 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);