mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
r2451: Fix from Henrik Nordstrom <hno@squid-cache.org> to allow
winbindd to return the correct number of groups when the groups array must be enlarged. Jeremy. (This used to be commit bcc769de4d60205209633887f2fb2f0ab6088cae)
This commit is contained in:
parent
848317b004
commit
1d886507be
@ -833,25 +833,38 @@ _nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
|
||||
|
||||
/* Skip primary group */
|
||||
|
||||
if (gid_list[i] == group) continue;
|
||||
if (gid_list[i] == group) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Filled buffer ? If so, resize. */
|
||||
|
||||
if (*start == *size) {
|
||||
long int newsize;
|
||||
gid_t *newgroups;
|
||||
|
||||
newsize = 2 * (*size);
|
||||
if (limit > 0) {
|
||||
if (*size == limit) {
|
||||
goto done;
|
||||
}
|
||||
newsize = MIN(newsize, limit);
|
||||
}
|
||||
|
||||
newgroups = realloc((*groups), newsize * sizeof(**groups));
|
||||
if (!newgroups) {
|
||||
*errnop = ENOMEM;
|
||||
ret = NSS_STATUS_NOTFOUND;
|
||||
goto done;
|
||||
}
|
||||
*groups = newgroups;
|
||||
*size = newsize;
|
||||
}
|
||||
|
||||
/* Add to buffer */
|
||||
|
||||
if (*start == *size && limit <= 0) {
|
||||
(*groups) = realloc(
|
||||
(*groups), (2 * (*size) + 1) * sizeof(**groups));
|
||||
if (! *groups) goto done;
|
||||
*size = 2 * (*size) + 1;
|
||||
}
|
||||
|
||||
if (*start == *size) goto done;
|
||||
|
||||
(*groups)[*start] = gid_list[i];
|
||||
*start += 1;
|
||||
|
||||
/* Filled buffer? */
|
||||
|
||||
if (*start == limit) goto done;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user