summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2000-08-24 16:00:20 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2000-08-24 16:00:20 +0000
commitb305c84f7c320ded4d46f05b94f69f7b3ba27f50 (patch)
tree6b1f846a37ea7acf2f891c9ce967c3f4afa372fa /usr.sbin
parentf9ec6ca5c9a018b95f876d2d8632f58db1fe94a8 (diff)
only loop through real groups; reported by dholland@eecs.harvard.edu
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/lpr/lpc/lpc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c
index 9d5e155a695..2bac5442bbf 100644
--- a/usr.sbin/lpr/lpc/lpc.c
+++ b/usr.sbin/lpr/lpc/lpc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lpc.c,v 1.5 1997/01/17 16:12:37 millert Exp $ */
+/* $OpenBSD: lpc.c,v 1.6 2000/08/24 16:00:19 deraadt Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)lpc.c 8.3 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: lpc.c,v 1.5 1997/01/17 16:12:37 millert Exp $";
+static char rcsid[] = "$OpenBSD: lpc.c,v 1.6 2000/08/24 16:00:19 deraadt Exp $";
#endif
#endif /* not lint */
@@ -308,6 +308,7 @@ ingroup(grname)
static gid_t groups[NGROUPS];
register gid_t gid;
register int i;
+ int maxgroups;
if (gptr == NULL) {
if ((gptr = getgrnam(grname)) == NULL) {
@@ -315,13 +316,13 @@ ingroup(grname)
grname);
return(0);
}
- if (getgroups(NGROUPS, groups) < 0) {
+ if ((maxgroups = getgroups(NGROUPS, groups)) < 0) {
perror("getgroups");
exit(1);
}
}
gid = gptr->gr_gid;
- for (i = 0; i < NGROUPS; i++)
+ for (i = 0; i < maxgroups; i++)
if (gid == groups[i])
return(1);
return(0);