summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-08-19 16:24:43 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-08-19 16:24:43 +0000
commitd93f1b0fec720572e9aea1878754d75e3f7c4162 (patch)
tree08378885a74f72a70f2bdf44ad26ced822bda3ef /lib/libc
parent94a6b31f7f0b2ef35fa6bdc9c484b20b3602b046 (diff)
do not reuse id's. also be more careful with maxgids.
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) {