diff options
author | se <se@FreeBSD.org> | 1995-02-17 17:36:09 +0000 |
---|---|---|
committer | se <se@FreeBSD.org> | 1995-02-17 17:36:09 +0000 |
commit | ecb476bce3ec0843045b6656804cf1a4cab99c35 (patch) | |
tree | dfc263751975f7b7d738f8f8fada6107c0b297a5 /lib/libc/gen/getgrouplist.c | |
parent | 9c3d4683ed9e19209b633564f40d9264da8a6f87 (diff) | |
download | FreeBSD-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.c | 7 |
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; |