summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/winbind_nss.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/source3/nsswitch/winbind_nss.c b/source3/nsswitch/winbind_nss.c
index a2816bfdd3..462c791277 100644
--- a/source3/nsswitch/winbind_nss.c
+++ b/source3/nsswitch/winbind_nss.c
@@ -785,9 +785,9 @@ _nss_winbind_getgrgid_r(gid_t gid,
/* Initialise supplementary groups */
NSS_STATUS
-_nss_winbind_initgroups(char *user, gid_t group, long int *start,
- long int *size, gid_t *groups, long int limit,
- int *errnop)
+_nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
+ long int *size, gid_t **groups, long int limit,
+ int *errnop)
{
NSS_STATUS ret;
struct winbindd_request request;
@@ -822,13 +822,15 @@ _nss_winbind_initgroups(char *user, gid_t group, long int *start,
/* Add to buffer */
if (*start == *size && limit <= 0) {
- groups = realloc(
- groups, 2 * (*size) * sizeof(*groups));
- if (!groups) goto done;
- *size *= 2;
+ (*groups) = realloc(
+ (*groups), (2 * (*size) + 1) * sizeof(**groups));
+ if (! *groups) goto done;
+ *size = 2 * (*size) + 1;
}
- groups[*start] = gid_list[i];
+ if (*start == *size) goto done;
+
+ (*groups)[*start] = gid_list[i];
*start += 1;
/* Filled buffer? */