diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/initgroups.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libc/gen/initgroups.c b/lib/libc/gen/initgroups.c index 3a3f513..82bbb3a 100644 --- a/lib/libc/gen/initgroups.c +++ b/lib/libc/gen/initgroups.c @@ -50,9 +50,14 @@ initgroups(uname, agroup) const char *uname; gid_t agroup; { - int groups[NGROUPS], ngroups; + int ngroups; + /* + * Provide space for one group more than NGROUPS to allow + * setgroups to fail and set errno. + */ + gid_t groups[NGROUPS + 1]; - ngroups = NGROUPS; + ngroups = NGROUPS + 1; getgrouplist(uname, agroup, groups, &ngroups); return (setgroups(ngroups, groups)); } |