diff options
author | brooks <brooks@FreeBSD.org> | 2010-01-12 07:49:34 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2010-01-12 07:49:34 +0000 |
commit | a093b41dafbd7defb7612a20d5672d938b8a54ed (patch) | |
tree | de91cf4c019f8024f0f1e02debf82cece77d60f2 /sys/kern/kern_prot.c | |
parent | 5d104fe3d7b80ec6fa42b6b91bdfb5c7b24c7775 (diff) | |
download | FreeBSD-src-a093b41dafbd7defb7612a20d5672d938b8a54ed.zip FreeBSD-src-a093b41dafbd7defb7612a20d5672d938b8a54ed.tar.gz |
Replace the static NGROUPS=NGROUPS_MAX+1=1024 with a dynamic
kern.ngroups+1. kern.ngroups can range from NGROUPS_MAX=1023 to
INT_MAX-1. Given that the Windows group limit is 1024, this range
should be sufficient for most applications.
MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_prot.c')
-rw-r--r-- | sys/kern/kern_prot.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 709bcb0..5a5c24c 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -283,7 +283,7 @@ getgroups(struct thread *td, register struct getgroups_args *uap) u_int ngrp; int error; - ngrp = MIN(uap->gidsetsize, NGROUPS); + ngrp = MIN(uap->gidsetsize, ngroups_max + 1); groups = malloc(ngrp * sizeof(*groups), M_TEMP, M_WAITOK); error = kern_getgroups(td, &ngrp, groups); if (error) @@ -796,7 +796,7 @@ setgroups(struct thread *td, struct setgroups_args *uap) gid_t *groups = NULL; int error; - if (uap->gidsetsize > NGROUPS) + if (uap->gidsetsize > ngroups_max + 1) return (EINVAL); groups = malloc(uap->gidsetsize * sizeof(gid_t), M_TEMP, M_WAITOK); error = copyin(uap->gidset, groups, uap->gidsetsize * sizeof(gid_t)); @@ -815,7 +815,7 @@ kern_setgroups(struct thread *td, u_int ngrp, gid_t *groups) struct ucred *newcred, *oldcred; int error; - if (ngrp > NGROUPS) + if (ngrp > ngroups_max + 1) return (EINVAL); AUDIT_ARG_GROUPSET(groups, ngrp); newcred = crget(); @@ -2022,14 +2022,14 @@ crsetgroups_locked(struct ucred *cr, int ngrp, gid_t *groups) /* * Copy groups in to a credential after expanding it if required. - * Truncate the list to NGROUPS if it is too large. + * Truncate the list to (ngroups_max + 1) if it is too large. */ void crsetgroups(struct ucred *cr, int ngrp, gid_t *groups) { - if (ngrp > NGROUPS) - ngrp = NGROUPS; + if (ngrp > ngroups_max + 1) + ngrp = ngroups_max + 1; crextend(cr, ngrp); crsetgroups_locked(cr, ngrp, groups); |