Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gen Return the full group count when it exceeds the...
details: https://anonhg.NetBSD.org/src/rev/e4798a73d9d3
branches: trunk
changeset: 471606:e4798a73d9d3
user: mycroft <mycroft%NetBSD.org@localhost>
date: Mon Apr 05 18:52:28 1999 +0000
description:
Return the full group count when it exceeds the maximum. Also DTRT if the
maximum is 0 (possibly used to size the list for memory allocation, rather
than core dumping).
diffstat:
lib/libc/gen/getgrouplist.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diffs (47 lines):
diff -r e5aac671d72e -r e4798a73d9d3 lib/libc/gen/getgrouplist.c
--- a/lib/libc/gen/getgrouplist.c Mon Apr 05 17:17:04 1999 +0000
+++ b/lib/libc/gen/getgrouplist.c Mon Apr 05 18:52:28 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getgrouplist.c,v 1.9 1998/02/03 18:23:44 perry Exp $ */
+/* $NetBSD: getgrouplist.c,v 1.10 1999/04/05 18:52:28 mycroft Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94";
#else
-__RCSID("$NetBSD: getgrouplist.c,v 1.9 1998/02/03 18:23:44 perry Exp $");
+__RCSID("$NetBSD: getgrouplist.c,v 1.10 1999/04/05 18:52:28 mycroft Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -73,7 +73,11 @@
/*
* install primary group
*/
- groups[ngroups++] = agroup;
+ if (ngroups < maxgroups)
+ groups[ngroups] = agroup;
+ else
+ ret = -1;
+ ngroups++;
/*
* Scan the group file to find additional groups.
@@ -84,11 +88,11 @@
continue;
for (i = 0; grp->gr_mem[i]; i++) {
if (!strcmp(grp->gr_mem[i], uname)) {
- if (ngroups >= maxgroups) {
+ if (ngroups < maxgroups)
+ groups[ngroups] = grp->gr_gid;
+ else
ret = -1;
- goto out;
- }
- groups[ngroups++] = grp->gr_gid;
+ ngroups++;
break;
}
}
Home |
Main Index |
Thread Index |
Old Index