diff options
Diffstat (limited to 'source/nsswitch')
-rw-r--r-- | source/nsswitch/wb_client.c | 9 | ||||
-rw-r--r-- | source/nsswitch/winbindd_group.c | 30 | ||||
-rw-r--r-- | source/nsswitch/winbindd_misc.c | 12 |
3 files changed, 36 insertions, 15 deletions
diff --git a/source/nsswitch/wb_client.c b/source/nsswitch/wb_client.c index 2a29773b9ec..666daa0aa3c 100644 --- a/source/nsswitch/wb_client.c +++ b/source/nsswitch/wb_client.c @@ -278,7 +278,7 @@ static int wb_getgroups(char *user, gid_t **groups) int winbind_initgroups(char *user, gid_t gid) { - gid_t *groups = NULL; + gid_t *tgr, *groups = NULL; int result; char *sep; @@ -310,13 +310,14 @@ int winbind_initgroups(char *user, gid_t gid) /* Add group to list if necessary */ if (!is_member) { - groups = Realloc(groups, sizeof(gid_t) * ngroups + 1); + tgr = (gid_t *)Realloc(groups, sizeof(gid_t) * ngroups + 1); - if (!groups) { + if (!tgr) { errno = ENOMEM; result = -1; goto done; - } + } else + groups = tgr; groups[ngroups] = gid; ngroups++; diff --git a/source/nsswitch/winbindd_group.c b/source/nsswitch/winbindd_group.c index ed4db07dda4..c6a54eb67c9 100644 --- a/source/nsswitch/winbindd_group.c +++ b/source/nsswitch/winbindd_group.c @@ -513,12 +513,21 @@ static BOOL get_sam_group_entries(struct getent_state *ent) /* Copy entries into return buffer */ if (num_entries) { + struct acct_info *tnl; - name_list = Realloc(name_list, + tnl = (struct acct_info *)Realloc(name_list, sizeof(struct acct_info) * (ent->num_sam_entries + num_entries)); + if (!tnl) { + DEBUG(0,("get_sam_group_entries: Realloc fail.\n")); + if (name_list) + free(name_list); + return False; + } else + name_list = tnl; + memcpy(&name_list[ent->num_sam_entries], sam_grp_entries, num_entries * sizeof(struct acct_info)); @@ -761,10 +770,10 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state) enum winbindd_result winbindd_list_groups(struct winbindd_cli_state *state) { - uint32 total_entries = 0; - struct winbindd_domain *domain; + uint32 total_entries = 0; + struct winbindd_domain *domain; struct getent_state groups; - char *extra_data = NULL; + char *ted, *extra_data = NULL; int extra_data_len = 0, i; DEBUG(3, ("[%5d]: list groups\n", state->pid)); @@ -794,12 +803,17 @@ enum winbindd_result winbindd_list_groups(struct winbindd_cli_state *state) account names to sizeof(fstring) = 128 characters. */ total_entries += groups.num_sam_entries; - extra_data = Realloc(extra_data, - sizeof(fstring) * total_entries); - if (!extra_data) { + ted = Realloc(extra_data, + sizeof(fstring) * total_entries); + + if (!ted) { + DEBUG(0,("winbindd_list_groups: failed to enlarge buffer!\n")); + if (extra_data) + free(extra_data); return WINBINDD_ERROR; - } + } else + extra_data = ted; /* Pack group list into extra data fields */ diff --git a/source/nsswitch/winbindd_misc.c b/source/nsswitch/winbindd_misc.c index 9520fc218b3..7a3003d0307 100644 --- a/source/nsswitch/winbindd_misc.c +++ b/source/nsswitch/winbindd_misc.c @@ -136,7 +136,7 @@ enum winbindd_result winbindd_list_trusted_domains(struct winbindd_cli_state { struct winbindd_domain *domain; int total_entries = 0, extra_data_len = 0; - char *extra_data = NULL; + char *ted, *extra_data = NULL; DEBUG(3, ("[%5d]: list trusted domains\n", state->pid)); @@ -149,10 +149,16 @@ enum winbindd_result winbindd_list_trusted_domains(struct winbindd_cli_state /* Add domain to list */ total_entries++; - extra_data = Realloc(extra_data, sizeof(fstring) * + ted = Realloc(extra_data, sizeof(fstring) * total_entries); - if (!extra_data) return WINBINDD_ERROR; + if (!ted) { + DEBUG(0,("winbindd_list_trusted_domains: failed to enlarge buffer!\n")); + if (extra_data) + free(extra_data); + return WINBINDD_ERROR; + } else + extra_data = ted; memcpy(&extra_data[extra_data_len], domain->name, strlen(domain->name)); |