Fix supplementary group list truncation for *BSD. We need to pass
authorjpeach <jpeach@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Wed, 13 Jun 2007 20:40:50 +0000 (20:40 +0000)
committerjpeach <jpeach@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Wed, 13 Jun 2007 20:40:50 +0000 (20:40 +0000)
the correct group list length and only truncate to NGROUPS_MAX if
it is too long.

git-svn-id: svn+ssh://svn.samba.org/data/svn/samba/branches/SAMBA_3_0@23470 0c0555d6-39d7-0310-84fc-f1cc0bd64818

source/lib/system.c

index 2cc7ef6ca42eda7b7a146a2ca671f198f8e3487c..13f743faa4f9e36505f607bfec33fa1f38a7a496 100644 (file)
@@ -1018,10 +1018,16 @@ static int sys_bsd_setgroups(gid_t primary_gid, int setlen, const gid_t *gidset)
                setlen++;
        }
 
+       if (setlen > max) {
+               DEBUG(10, ("forced to truncate group list from %d to %d\n",
+                       setlen, max));
+               setlen = max;
+       }
+
 #if defined(BROKEN_GETGROUPS)
-       ret = sys_broken_setgroups(max, new_gidset ? new_gidset : gidset);
+       ret = sys_broken_setgroups(setlen, new_gidset ? new_gidset : gidset);
 #else
-       ret = setgroups(max, new_gidset ? new_gidset : gidset);
+       ret = setgroups(setlen, new_gidset ? new_gidset : gidset);
 #endif
 
        if (new_gidset) {