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:
Stefan Eßer 1995-02-17 17:36:09 +00:00
parent a1c128ae2a
commit f067e922a9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=6530

View File

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