* src/groupmems.c (whoami): Make sure usr and grp are not NULL

before dereferencing them.
This commit is contained in:
nekral-guest 2008-07-27 22:30:31 +00:00
parent 5a0715fd6c
commit d6f96fa07e
2 changed files with 8 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2008-07-27 Nicolas François <nicolas.francois@centraliens.net>
* src/groupmems.c (whoami): Make sure usr and grp are not NULL
before dereferencing them.
2008-07-27 Nicolas François <nicolas.francois@centraliens.net>
* src/groupmems.c: Use xstrdup() rather than strdup().

View File

@ -85,7 +85,9 @@ static char *whoami (void)
/* local, no need for xgetpwuid */
struct passwd *usr = getpwuid (getuid ());
if (0 == strcmp (usr->pw_name, grp->gr_name)) {
if ( (NULL != usr)
&& (NULL != grp)
&& (0 == strcmp (usr->pw_name, grp->gr_name))) {
return xstrdup (usr->pw_name);
} else {
return NULL;