diff options
author | Jeremy Allison <jra@samba.org> | 2004-09-20 20:18:19 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:52:43 -0500 |
commit | 1d886507be8f5bf44fc0228a7d8bc5ce9be2e142 (patch) | |
tree | 0b0d946030ca08c290081645bb72b2989ca21806 | |
parent | 848317b00401e5172a38ad684cf6cfc98834b2f2 (diff) | |
download | samba-1d886507be8f5bf44fc0228a7d8bc5ce9be2e142.tar.gz samba-1d886507be8f5bf44fc0228a7d8bc5ce9be2e142.tar.bz2 samba-1d886507be8f5bf44fc0228a7d8bc5ce9be2e142.zip |
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)
-rw-r--r-- | source3/nsswitch/winbind_nss_linux.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/source3/nsswitch/winbind_nss_linux.c b/source3/nsswitch/winbind_nss_linux.c index ae2bcc7ade..a6d0bfe4e8 100644 --- a/source3/nsswitch/winbind_nss_linux.c +++ b/source3/nsswitch/winbind_nss_linux.c @@ -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; - - /* Add to buffer */ + if (gid_list[i] == group) { + continue; + } - if (*start == *size && limit <= 0) { - (*groups) = realloc( - (*groups), (2 * (*size) + 1) * sizeof(**groups)); - if (! *groups) goto done; - *size = 2 * (*size) + 1; + /* 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; } - if (*start == *size) goto done; + /* Add to buffer */ (*groups)[*start] = gid_list[i]; *start += 1; - - /* Filled buffer? */ - - if (*start == limit) goto done; } } |