More robust when going through group members

This commit is contained in:
Pierre Pronchery 2007-09-27 01:08:57 +00:00
parent c13c4c2528
commit da533ad0e5

View File

@ -99,7 +99,7 @@ static int _id_G(char * user, int flagn)
setgrent();
for(gr = getgrent(); gr != NULL; gr = getgrent())
{
for(p = gr->gr_mem; *p != NULL; p++)
for(p = gr->gr_mem; p != NULL && *p != NULL; p++)
{
if(strcmp(user, *p) == 0)
{
@ -222,7 +222,7 @@ static int _id_all(char * user)
printf("%s%u(%s)", " groups=", (unsigned)pw->pw_gid, user);
setgrent();
for(gr = getgrent(); gr != NULL; gr = getgrent())
for(p = gr->gr_mem; *p != NULL; p++)
for(p = gr->gr_mem; p != NULL && *p != NULL; p++)
if(strcmp(user, *p) == 0)
printf(",%u(%s)", (unsigned)gr->gr_gid,
gr->gr_name);