diff options
| author | Kyle Evans <kevans@FreeBSD.org> | 2025-08-15 04:06:09 +0000 |
|---|---|---|
| committer | Kyle Evans <kevans@FreeBSD.org> | 2025-08-15 04:06:09 +0000 |
| commit | 9da2fe96ff2ea227e4d5f03ef92b55aabeabb7fc (patch) | |
| tree | c2b8913ea97e90b3473cd2e75af5d6e8e1c93fd8 /usr.sbin | |
| parent | c75550e499971549b31d514ab139b80297c14792 (diff) | |
Diffstat (limited to 'usr.sbin')
| -rw-r--r-- | usr.sbin/chroot/chroot.c | 9 | ||||
| -rw-r--r-- | usr.sbin/lpr/lpc/lpc.c | 2 |
2 files changed, 4 insertions, 7 deletions
diff --git a/usr.sbin/chroot/chroot.c b/usr.sbin/chroot/chroot.c index 7ec5a00b50f0..e1af0a4131d3 100644 --- a/usr.sbin/chroot/chroot.c +++ b/usr.sbin/chroot/chroot.c @@ -147,15 +147,10 @@ main(int argc, char *argv[]) gid = resolve_group(group); if (grouplist != NULL) { - ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1; + ngroups_max = sysconf(_SC_NGROUPS_MAX); if ((gidlist = malloc(sizeof(gid_t) * ngroups_max)) == NULL) err(1, "malloc"); - /* Populate the egid slot in our groups to avoid accidents. */ - if (gid == 0) - gidlist[0] = getegid(); - else - gidlist[0] = gid; - for (gids = 1; (p = strsep(&grouplist, ",")) != NULL && + for (gids = 0; (p = strsep(&grouplist, ",")) != NULL && gids < ngroups_max; ) { if (*p == '\0') continue; diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c index a3da852de46e..b4db5bb2e29f 100644 --- a/usr.sbin/lpr/lpc/lpc.c +++ b/usr.sbin/lpr/lpc/lpc.c @@ -358,6 +358,8 @@ ingroup(const char *grname) err(1, "getgroups"); } gid = gptr->gr_gid; + if (gid == getegid()) + return(1); for (i = 0; i < ngroups; i++) if (gid == groups[i]) return(1); |
