- 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
This commit is contained in:
delphij 2011-10-12 01:19:12 +00:00
parent 16b6dcb054
commit c0ed9a753b

View File

@ -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;