diff options
author | dds <dds@FreeBSD.org> | 2003-11-19 15:51:26 +0000 |
---|---|---|
committer | dds <dds@FreeBSD.org> | 2003-11-19 15:51:26 +0000 |
commit | 36934d35fec44eaefcb112d5d544542c19a0594a (patch) | |
tree | 240c535a27403b15a86a4cfdd3f8384c585844ac /lib | |
parent | e9c1e3387f290e428491955ba285c2e8f45683a8 (diff) | |
download | FreeBSD-src-36934d35fec44eaefcb112d5d544542c19a0594a.zip FreeBSD-src-36934d35fec44eaefcb112d5d544542c19a0594a.tar.gz |
Fix problem where initgroups would silently truncate groups with
more than NGROUP elements without providing the opportunity to
setgroups to fail and correctly return error and set errno.
MFC after: 2 weeks
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)); } |