mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
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
1 changed files with 7 additions and 2 deletions
|
|
@ -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 a new issue