diff options
| author | Brooks Davis <brooks@FreeBSD.org> | 2009-06-19 15:58:24 +0000 |
|---|---|---|
| committer | Brooks Davis <brooks@FreeBSD.org> | 2009-06-19 15:58:24 +0000 |
| commit | 54404cfb13d40e474f72d3c75de1f4db3417df64 (patch) | |
| tree | b7d4401847de9bebf98c6fe35d5b61bfd749c7dc /usr.sbin/chroot | |
| parent | 68cc62cec1384a3e08391dc734b0ff16f6eda869 (diff) | |
Notes
Diffstat (limited to 'usr.sbin/chroot')
| -rw-r--r-- | usr.sbin/chroot/chroot.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/chroot/chroot.c b/usr.sbin/chroot/chroot.c index f33db7a24588..cc924a027bc5 100644 --- a/usr.sbin/chroot/chroot.c +++ b/usr.sbin/chroot/chroot.c @@ -69,9 +69,10 @@ main(argc, argv) struct passwd *pw; char *endp, *p; const char *shell; - gid_t gid, gidlist[NGROUPS_MAX]; + gid_t gid, *gidlist; uid_t uid; int ch, gids; + long ngroups_max; gid = 0; uid = 0; @@ -117,8 +118,11 @@ main(argc, argv) } } + ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1; + if ((gidlist = malloc(sizeof(gid_t) * ngroups_max)) == NULL) + err(1, "malloc"); for (gids = 0; - (p = strsep(&grouplist, ",")) != NULL && gids < NGROUPS_MAX; ) { + (p = strsep(&grouplist, ",")) != NULL && gids < ngroups_max; ) { if (*p == '\0') continue; @@ -135,7 +139,7 @@ main(argc, argv) } gids++; } - if (p != NULL && gids == NGROUPS_MAX) + if (p != NULL && gids == ngroups_max) errx(1, "too many supplementary groups provided"); if (user != NULL) { |
