Protect against duplicate gids in group list (as could be the

result of being a member of some group in both /etc/group and YP).
This commit is contained in:
se 1995-02-17 17:36:09 +00:00
parent 9c3d4683ed
commit ecb476bce3

View File

@ -70,8 +70,10 @@ getgrouplist(uname, agroup, groups, grpcnt)
*/
setgrent();
while (grp = getgrent()) {
if (grp->gr_gid == agroup)
continue;
for (i = 1; i < ngroups; i++) {
if (grp->gr_gid == groups[i])
goto skip;
}
if (ngroups >= maxgroups) {
ret = -1;
break;
@ -82,6 +84,7 @@ getgrouplist(uname, agroup, groups, grpcnt)
break;
}
}
skip:
}
endgrent();
*grpcnt = ngroups;