summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getgrouplist.c
diff options
context:
space:
mode:
authorse <se@FreeBSD.org>1995-02-17 17:36:09 +0000
committerse <se@FreeBSD.org>1995-02-17 17:36:09 +0000
commitecb476bce3ec0843045b6656804cf1a4cab99c35 (patch)
treedfc263751975f7b7d738f8f8fada6107c0b297a5 /lib/libc/gen/getgrouplist.c
parent9c3d4683ed9e19209b633564f40d9264da8a6f87 (diff)
downloadFreeBSD-src-ecb476bce3ec0843045b6656804cf1a4cab99c35.zip
FreeBSD-src-ecb476bce3ec0843045b6656804cf1a4cab99c35.tar.gz
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).
Diffstat (limited to 'lib/libc/gen/getgrouplist.c')
-rw-r--r--lib/libc/gen/getgrouplist.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libc/gen/getgrouplist.c b/lib/libc/gen/getgrouplist.c
index 34ab4ea..41eaf5e 100644
--- a/lib/libc/gen/getgrouplist.c
+++ b/lib/libc/gen/getgrouplist.c
@@ -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;
OpenPOWER on IntegriCloud