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
This commit is contained in:
parent
6006b8f4c6
commit
434c74760f
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user