nsstest: Allocate the correct sized buffer for initgroups
authorAndrew Bartlett <abartlet@samba.org>
Mon, 20 Feb 2012 02:46:29 +0000 (13:46 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 20 Feb 2012 04:23:04 +0000 (05:23 +0100)
Found by chance due to a re-order of the tests to start s3member
earlier and chasing down a malloc Abort into a valgrind error.  Only
happens when a user has more than 4 groups.

Andrew Bartlett

Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Mon Feb 20 05:23:04 CET 2012 on sn-devel-104

nsswitch/nsstest.c

index d84e028513b09009ae57c4fa9b2c1453944b9900..e2b39bc6bea9ae2bdb6699f008d5cbf8dbb3441d 100644 (file)
@@ -370,7 +370,7 @@ static void nss_test_initgroups(char *name, gid_t gid)
        int i;
        NSS_STATUS status;
 
-       groups = (gid_t *)malloc(size);
+       groups = (gid_t *)malloc(sizeof(gid_t) * size);
        groups[0] = gid;
 
        status = nss_initgroups(name, gid, &groups, &start, &size);