summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/getgrouplist.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/libc/gen/getgrouplist.c b/lib/libc/gen/getgrouplist.c
index 37cc2b5c5d5..9ee03354eb9 100644
--- a/lib/libc/gen/getgrouplist.c
+++ b/lib/libc/gen/getgrouplist.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getgrouplist.c,v 1.5 1997/07/09 00:28:21 millert Exp $";
+static char rcsid[] = "$OpenBSD: getgrouplist.c,v 1.6 1997/08/19 16:24:42 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -60,6 +60,10 @@ getgrouplist(uname, agroup, groups, grpcnt)
/*
* install primary group
*/
+ if (ngroups >= maxgroups) {
+ *grpcnt = ngroups;
+ return (-1);
+ }
groups[ngroups++] = agroup;
/*
@@ -69,6 +73,11 @@ getgrouplist(uname, agroup, groups, grpcnt)
while ((grp = getgrent())) {
if (grp->gr_gid == agroup)
continue;
+ for (i = 0; i < ngroups; i++)
+ if (groups[i] == grp->gr_gid)
+ break;
+ if (groups[i] == grp->gr_gid)
+ continue;
for (i = 0; grp->gr_mem[i]; i++) {
if (!strcmp(grp->gr_mem[i], uname)) {
if (ngroups >= maxgroups) {