Pass getgrouplist() NGROUPS_MAX+1, not NGROUPS_MAX so we have room

for the primary gid.
This commit is contained in:
Todd C. Miller
2018-09-22 12:55:44 -06:00
parent 72ce2c807b
commit d8870177c2

View File

@@ -84,6 +84,7 @@ sudo_getgrouplist2_v1(const char *name, GETGROUPS_T basegid,
grpsize = (int)sysconf(_SC_NGROUPS_MAX);
if (grpsize < 0)
grpsize = NGROUPS_MAX;
grpsize++; /* include space for the primary gid */
/*
* It is possible to belong to more groups in the group database
* than NGROUPS_MAX.