]> granicus.if.org Git - sudo/commitdiff
Pass getgrouplist() NGROUPS_MAX+1, not NGROUPS_MAX so we have room
authorTodd C. Miller <Todd.Miller@sudo.ws>
Sat, 22 Sep 2018 18:55:44 +0000 (12:55 -0600)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Sat, 22 Sep 2018 18:55:44 +0000 (12:55 -0600)
for the primary gid.

lib/util/getgrouplist.c

index 4d47ade82fcf9795e24d4d5f723e1109c76f3bea..b791d260e9bbf6f28e6ceb20ed0d165def2809db 100644 (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.