mirror of
https://github.com/samba-team/samba.git
synced 2025-01-24 02:04:21 +03:00
s3:lib: Fix incorrect logic in sys_broken_getgroups()
If setlen == 0 then the second argument must be ignored. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12747 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
parent
600f8787e3
commit
60af864f75
@ -790,12 +790,11 @@ int groups_max(void)
|
||||
|
||||
static int sys_broken_getgroups(int setlen, gid_t *gidset)
|
||||
{
|
||||
GID_T gid;
|
||||
GID_T *group_list;
|
||||
int i, ngroups;
|
||||
|
||||
if(setlen == 0) {
|
||||
return getgroups(setlen, &gid);
|
||||
return getgroups(0, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -808,9 +807,6 @@ static int sys_broken_getgroups(int setlen, gid_t *gidset)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setlen == 0)
|
||||
setlen = groups_max();
|
||||
|
||||
if((group_list = SMB_MALLOC_ARRAY(GID_T, setlen)) == NULL) {
|
||||
DEBUG(0,("sys_getgroups: Malloc fail.\n"));
|
||||
return -1;
|
||||
@ -823,6 +819,12 @@ static int sys_broken_getgroups(int setlen, gid_t *gidset)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* We're safe here as if ngroups > setlen then
|
||||
* getgroups *must* return EINVAL.
|
||||
* pubs.opengroup.org/onlinepubs/009695399/functions/getgroups.html
|
||||
*/
|
||||
|
||||
for(i = 0; i < ngroups; i++)
|
||||
gidset[i] = (gid_t)group_list[i];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user