Page MenuHomeFreeBSD

D51508.id159172.diff
No OneTemporary

D51508.id159172.diff

diff --git a/usr.sbin/chroot/chroot.c b/usr.sbin/chroot/chroot.c
--- a/usr.sbin/chroot/chroot.c
+++ b/usr.sbin/chroot/chroot.c
@@ -111,7 +111,12 @@
ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1;
if ((gidlist = malloc(sizeof(gid_t) * ngroups_max)) == NULL)
err(1, "malloc");
- for (gids = 0;
+ /* 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 && gids < ngroups_max; ) {
if (*p == '\0')
continue;

File Metadata

Mime Type
text/plain
Expires
Thu, Aug 6, 5:18 AM (17 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36005976
Default Alt Text
D51508.id159172.diff (553 B)

Event Timeline