deal with NULL gr_mem here too

This commit is contained in:
Todd C. Miller
2014-05-06 19:32:34 -06:00
parent e54fe5a269
commit 17cbfea8b7
3 changed files with 11 additions and 9 deletions

View File

@@ -320,7 +320,7 @@ getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroupsp)
setgrent(); setgrent();
while ((grp = getgrent()) != NULL) { while ((grp = getgrent()) != NULL) {
if (grp->gr_gid == basegid) if (grp->gr_gid == basegid || grp->gr_mem == NULL)
continue; continue;
for (i = 0; grp->gr_mem[i] != NULL; i++) { for (i = 0; grp->gr_mem[i] != NULL; i++) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2010-2013 Todd C. Miller <Todd.Miller@courtesan.com> * Copyright (c) 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@@ -121,7 +121,7 @@ sample_query(const char *user, const char *group, const struct passwd *pwd)
char **member; char **member;
grp = mygetgrnam(group); grp = mygetgrnam(group);
if (grp != NULL) { if (grp != NULL && grp->gr_mem != NULL) {
for (member = grp->gr_mem; *member != NULL; member++) { for (member = grp->gr_mem; *member != NULL; member++) {
if (strcasecmp(user, *member) == 0) if (strcasecmp(user, *member) == 0)
return true; return true;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2010-2013 Todd C. Miller <Todd.Miller@courtesan.com> * Copyright (c) 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@@ -140,11 +140,13 @@ sysgroup_query(const char *user, const char *group, const struct passwd *pwd)
grp = sysgroup_getgrgid(gid); grp = sysgroup_getgrgid(gid);
} }
if (grp != NULL) { if (grp != NULL) {
for (member = grp->gr_mem; *member != NULL; member++) { if (grp->gr_mem != NULL) {
if (strcasecmp(user, *member) == 0) { for (member = grp->gr_mem; *member != NULL; member++) {
if (sysgroup_gr_delref) if (strcasecmp(user, *member) == 0) {
sysgroup_gr_delref(grp); if (sysgroup_gr_delref)
return true; sysgroup_gr_delref(grp);
return true;
}
} }
} }
if (sysgroup_gr_delref) if (sysgroup_gr_delref)