Skip to content

Commit

Permalink
nscd: Deallocate existing user names in file parser
Browse files Browse the repository at this point in the history
This avoids a theoretical memory leak (theoretical because it depends on
multiple server-user/stat-user directives in the configuration file).
  • Loading branch information
fweimer-rh committed Aug 14, 2018
1 parent 17b2650 commit 2d7acfa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-08-14 Florian Weimer <[email protected]>

* nscd/nscd_conf.c (nscd_parse_file): Deallocate old storage for
server_user, stat_user.

2018-08-13 Joseph Myers <[email protected]>

* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
Expand Down
6 changes: 5 additions & 1 deletion nscd/nscd_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,18 @@ 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)
{
if (arg1 == NULL)
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);
Expand Down

0 comments on commit 2d7acfa

Please sign in to comment.