summaryrefslogtreecommitdiffstats
path: root/usr.bin/newgrp/newgrp.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2011-10-12 01:19:12 +0000
committerdelphij <delphij@FreeBSD.org>2011-10-12 01:19:12 +0000
commitc0ed9a753bce0546d880b271dc60012b3a999e7b (patch)
treefcf4ffdc6076c9f42fd266fb5f3ef1e84bffb7cd /usr.bin/newgrp/newgrp.c
parent16b6dcb0546d80677df3db7a24b0069d738baceb (diff)
downloadFreeBSD-src-c0ed9a753bce0546d880b271dc60012b3a999e7b.zip
FreeBSD-src-c0ed9a753bce0546d880b271dc60012b3a999e7b.tar.gz
- Fix an off-by-one bug in addgroup().
- Fix the error message when setgid() failed. PR: bin/161509 Submitted by: Jeremy Huddleston <jeremyhu apple com> MFC after: 2 weeks
Diffstat (limited to 'usr.bin/newgrp/newgrp.c')
-rw-r--r--usr.bin/newgrp/newgrp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/newgrp/newgrp.c b/usr.bin/newgrp/newgrp.c
index 91b62a5..8198301 100644
--- a/usr.bin/newgrp/newgrp.c
+++ b/usr.bin/newgrp/newgrp.c
@@ -140,7 +140,7 @@ restoregrps(void)
if (initres < 0)
warn("initgroups");
if (setres < 0)
- warn("setgroups");
+ warn("setgid");
}
static void
@@ -220,7 +220,7 @@ addgroup(const char *grpname)
/* Add old effective gid to supp. list if it does not exist. */
if (egid != grp->gr_gid && !inarray(egid, grps, ngrps)) {
- if (ngrps == ngrps_max)
+ if (ngrps + 1 >= ngrps_max)
warnx("too many groups");
else {
grps[ngrps++] = egid;
OpenPOWER on IntegriCloud