diff options
Diffstat (limited to 'source3/nsswitch')
-rw-r--r-- | source3/nsswitch/wb_client.c | 2 | ||||
-rw-r--r-- | source3/nsswitch/winbindd.c | 3 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_acct.c | 8 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_ads.c | 34 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_cache.c | 28 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_cm.c | 8 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_dual.c | 2 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_group.c | 28 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_misc.c | 6 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_pam.c | 8 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_passdb.c | 18 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_rpc.c | 19 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_user.c | 13 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_util.c | 4 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_wins.c | 2 | ||||
-rw-r--r-- | source3/nsswitch/wins.c | 2 |
16 files changed, 84 insertions, 101 deletions
diff --git a/source3/nsswitch/wb_client.c b/source3/nsswitch/wb_client.c index a1c71becf0..3a920c1134 100644 --- a/source3/nsswitch/wb_client.c +++ b/source3/nsswitch/wb_client.c @@ -326,7 +326,7 @@ int winbind_initgroups(char *user, gid_t gid) /* Add group to list if necessary */ if (!is_member) { - tgr = (gid_t *)Realloc(groups, sizeof(gid_t) * ngroups + 1); + tgr = SMB_REALLOC_ARRAY(groups, gid_t, ngroups + 1); if (!tgr) { errno = ENOMEM; diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index 455fb74f17..6f4a0a2753 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -357,8 +357,7 @@ static void new_connection(int listen_sock, BOOL privileged) /* Create new connection structure */ - if ((state = (struct winbindd_cli_state *) - malloc(sizeof(*state))) == NULL) + if ((state = SMB_MALLOC_P(struct winbindd_cli_state)) == NULL) return; ZERO_STRUCTP(state); diff --git a/source3/nsswitch/winbindd_acct.c b/source3/nsswitch/winbindd_acct.c index e6496695cb..2c8b7cae28 100644 --- a/source3/nsswitch/winbindd_acct.c +++ b/source3/nsswitch/winbindd_acct.c @@ -219,7 +219,7 @@ static WINBINDD_GR* string2group( char *string ) if ( num_gr_members ) { fstring buffer; - gr_members = (char**)smb_xmalloc(sizeof(char*)*(num_gr_members+1)); + gr_members = SMB_XMALLOC_ARRAY(char*, num_gr_members+1); i = 0; while ( next_token(&str, buffer, ",", sizeof(buffer)) && i<num_gr_members ) { @@ -284,7 +284,7 @@ static char* group2string( const WINBINDD_GR *grp ) member = grp->gr_mem[num_members]; } - gr_mem_str = smb_xmalloc(size); + gr_mem_str = SMB_XMALLOC_ARRAY(char, size); for ( i=0; i<num_members; i++ ) { snprintf( &gr_mem_str[idx], size-idx, "%s,", grp->gr_mem[i] ); @@ -295,7 +295,7 @@ static char* group2string( const WINBINDD_GR *grp ) } else { /* no members */ - gr_mem_str = smb_xmalloc(sizeof(fstring)); + gr_mem_str = SMB_XMALLOC_ARRAY(char, sizeof(fstring)); fstrcpy( gr_mem_str, "" ); } @@ -639,7 +639,7 @@ static BOOL wb_addgrpmember( WINBINDD_GR *grp, const char *user ) } /* add one new slot and keep an extra for the terminating NULL */ - members = Realloc( grp->gr_mem, (grp->num_gr_mem+2)*sizeof(char*) ); + members = SMB_REALLOC_ARRAY( grp->gr_mem, char *, grp->num_gr_mem+2); if ( !members ) return False; diff --git a/source3/nsswitch/winbindd_ads.c b/source3/nsswitch/winbindd_ads.c index 1392c96fb1..f77b76cd9a 100644 --- a/source3/nsswitch/winbindd_ads.c +++ b/source3/nsswitch/winbindd_ads.c @@ -72,7 +72,7 @@ static ADS_STRUCT *ads_cached_connection(struct winbindd_domain *domain) ads->auth.password = secrets_fetch_machine_password(lp_workgroup(), NULL, NULL); SAFE_FREE(ads->auth.realm); - ads->auth.realm = strdup(lp_realm()); + ads->auth.realm = SMB_STRDUP(lp_realm()); status = ads_connect(ads); if (!ADS_ERR_OK(status) || !ads->config.realm) { @@ -146,7 +146,7 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, goto done; } - (*info) = talloc_zero(mem_ctx, count * sizeof(**info)); + (*info) = TALLOC_ZERO_ARRAY(mem_ctx, WINBIND_USERINFO, count); if (!*info) { status = NT_STATUS_NO_MEMORY; goto done; @@ -179,7 +179,7 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, continue; } - sid2 = talloc(mem_ctx, sizeof(*sid2)); + sid2 = TALLOC_P(mem_ctx, DOM_SID); if (!sid2) { status = NT_STATUS_NO_MEMORY; goto done; @@ -248,7 +248,7 @@ static NTSTATUS enum_dom_groups(struct winbindd_domain *domain, goto done; } - (*info) = talloc_zero(mem_ctx, count * sizeof(**info)); + (*info) = TALLOC_ZERO_ARRAY(mem_ctx, struct acct_info, count); if (!*info) { status = NT_STATUS_NO_MEMORY; goto done; @@ -421,7 +421,7 @@ static NTSTATUS query_user(struct winbindd_domain *domain, goto done; } - sid2 = talloc(mem_ctx, sizeof(*sid2)); + sid2 = TALLOC_P(mem_ctx, DOM_SID); if (!sid2) { status = NT_STATUS_NO_MEMORY; goto done; @@ -501,7 +501,7 @@ static NTSTATUS lookup_usergroups_alt(struct winbindd_domain *domain, goto done; } - (*user_gids) = talloc_zero(mem_ctx, sizeof(**user_gids) * (count + 1)); + (*user_gids) = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID *, count + 1); (*user_gids)[0] = primary_group; *num_groups = 1; @@ -516,7 +516,7 @@ static NTSTATUS lookup_usergroups_alt(struct winbindd_domain *domain, if (sid_equal(&group_sid, primary_group)) continue; - (*user_gids)[*num_groups] = talloc(mem_ctx, sizeof(***user_gids)); + (*user_gids)[*num_groups] = TALLOC_P(mem_ctx, DOM_SID); if (!(*user_gids)[*num_groups]) { status = NT_STATUS_NO_MEMORY; goto done; @@ -610,7 +610,7 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain, num_groups, user_gids); } - (*user_gids) = talloc_zero(mem_ctx, sizeof(**user_gids) * (count + 1)); + (*user_gids) = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID *, count + 1); (*user_gids)[0] = primary_group; *num_groups = 1; @@ -618,7 +618,7 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain, for (i=0;i<count;i++) { if (sid_equal(&sids[i], primary_group)) continue; - (*user_gids)[*num_groups] = talloc(mem_ctx, sizeof(***user_gids)); + (*user_gids)[*num_groups] = TALLOC_P(mem_ctx, DOM_SID); if (!(*user_gids)[*num_groups]) { status = NT_STATUS_NO_MEMORY; goto done; @@ -685,7 +685,7 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain, members = NULL; num_members = 0; - attrs = talloc(mem_ctx, 3 * sizeof(*attrs)); + attrs = TALLOC_ARRAY(mem_ctx, const char *, 3); attrs[1] = talloc_strdup(mem_ctx, "usnChanged"); attrs[2] = NULL; @@ -751,9 +751,9 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain, the problem is that the members are in the form of distinguised names */ - (*sid_mem) = talloc_zero(mem_ctx, sizeof(**sid_mem) * num_members); - (*name_types) = talloc_zero(mem_ctx, sizeof(**name_types) * num_members); - (*names) = talloc_zero(mem_ctx, sizeof(**names) * num_members); + (*sid_mem) = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID *, num_members); + (*name_types) = TALLOC_ZERO_ARRAY(mem_ctx, uint32, num_members); + (*names) = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_members); for (i=0;i<num_members;i++) { uint32 name_type; @@ -763,7 +763,7 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain, if (dn_lookup(ads, mem_ctx, members[i], &name, &name_type, &sid)) { (*names)[*num_names] = name; (*name_types)[*num_names] = name_type; - (*sid_mem)[*num_names] = talloc(mem_ctx, sizeof(***sid_mem)); + (*sid_mem)[*num_names] = TALLOC_P(mem_ctx, DOM_SID); if (!(*sid_mem)[*num_names]) { status = NT_STATUS_NO_MEMORY; goto done; @@ -850,19 +850,19 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain, /* Allocate memory for trusted domain names and sids */ - if ( !(*names = (char **)talloc(mem_ctx, sizeof(char *) * count)) ) { + if ( !(*names = TALLOC_ARRAY(mem_ctx, char *, count)) ) { DEBUG(0, ("trusted_domains: out of memory\n")); result = NT_STATUS_NO_MEMORY; goto done; } - if ( !(*alt_names = (char **)talloc(mem_ctx, sizeof(char *) * count)) ) { + if ( !(*alt_names = TALLOC_ARRAY(mem_ctx, char *, count)) ) { DEBUG(0, ("trusted_domains: out of memory\n")); result = NT_STATUS_NO_MEMORY; goto done; } - if ( !(*dom_sids = (DOM_SID *)talloc(mem_ctx, sizeof(DOM_SID) * count)) ) { + if ( !(*dom_sids = TALLOC_ARRAY(mem_ctx, DOM_SID, count)) ) { DEBUG(0, ("trusted_domains: out of memory\n")); result = NT_STATUS_NO_MEMORY; goto done; diff --git a/source3/nsswitch/winbindd_cache.c b/source3/nsswitch/winbindd_cache.c index a6ebafca96..ba274ec8e7 100644 --- a/source3/nsswitch/winbindd_cache.c +++ b/source3/nsswitch/winbindd_cache.c @@ -136,7 +136,7 @@ static struct winbind_cache *get_cache(struct winbindd_domain *domain) if (ret) return ret; - ret = smb_xmalloc(sizeof(*ret)); + ret = SMB_XMALLOC_P(struct winbind_cache); ZERO_STRUCTP(ret); wcache = ret; @@ -209,7 +209,7 @@ static char *centry_string(struct cache_entry *centry, TALLOC_CTX *mem_ctx) smb_panic("centry_string"); } - ret = talloc(mem_ctx, len+1); + ret = TALLOC(mem_ctx, len+1); if (!ret) { smb_panic("centry_string out of memory\n"); } @@ -227,7 +227,7 @@ static DOM_SID *centry_sid(struct cache_entry *centry, TALLOC_CTX *mem_ctx) DOM_SID *sid; char *sid_string; - sid = talloc(mem_ctx, sizeof(*sid)); + sid = TALLOC_P(mem_ctx, DOM_SID); if (!sid) return NULL; @@ -450,7 +450,7 @@ static struct cache_entry *wcache_fetch(struct winbind_cache *cache, return NULL; } - centry = smb_xmalloc(sizeof(*centry)); + centry = SMB_XMALLOC_P(struct cache_entry); centry->data = (unsigned char *)data.dptr; centry->len = data.dsize; centry->ofs = 0; @@ -501,7 +501,7 @@ static void centry_expand(struct cache_entry *centry, uint32 len) if (centry->len - centry->ofs >= len) return; centry->len *= 2; - p = realloc(centry->data, centry->len); + p = SMB_REALLOC(centry->data, centry->len); if (!p) { DEBUG(0,("out of memory: needed %d bytes in centry_expand\n", centry->len)); smb_panic("out of memory in centry_expand"); @@ -568,10 +568,10 @@ struct cache_entry *centry_start(struct winbindd_domain *domain, NTSTATUS status if (!wcache->tdb) return NULL; - centry = smb_xmalloc(sizeof(*centry)); + centry = SMB_XMALLOC_P(struct cache_entry); centry->len = 8192; /* reasonable default */ - centry->data = smb_xmalloc(centry->len); + centry->data = SMB_XMALLOC_ARRAY(char, centry->len); centry->ofs = 0; centry->sequence_number = domain->sequence_number; centry_put_uint32(centry, NT_STATUS_V(status)); @@ -684,7 +684,7 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, if (*num_entries == 0) goto do_cached; - (*info) = talloc(mem_ctx, sizeof(**info) * (*num_entries)); + (*info) = TALLOC_ARRAY(mem_ctx, WINBIND_USERINFO, *num_entries); if (! (*info)) smb_panic("query_user_list out of memory"); for (i=0; i<(*num_entries); i++) { @@ -793,7 +793,7 @@ static NTSTATUS enum_dom_groups(struct winbindd_domain *domain, if (*num_entries == 0) goto do_cached; - (*info) = talloc(mem_ctx, sizeof(**info) * (*num_entries)); + (*info) = TALLOC_ARRAY(mem_ctx, struct acct_info, *num_entries); if (! (*info)) smb_panic("enum_dom_groups out of memory"); for (i=0; i<(*num_entries); i++) { @@ -866,7 +866,7 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain, if (*num_entries == 0) goto do_cached; - (*info) = talloc(mem_ctx, sizeof(**info) * (*num_entries)); + (*info) = TALLOC_ARRAY(mem_ctx, struct acct_info, *num_entries); if (! (*info)) smb_panic("enum_dom_groups out of memory"); for (i=0; i<(*num_entries); i++) { @@ -1156,7 +1156,7 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain, if (*num_groups == 0) goto do_cached; - (*user_gids) = talloc(mem_ctx, sizeof(**user_gids) * (*num_groups)); + (*user_gids) = TALLOC_ARRAY(mem_ctx, DOM_SID *, *num_groups); if (! (*user_gids)) smb_panic("lookup_usergroups out of memory"); for (i=0; i<(*num_groups); i++) { @@ -1227,9 +1227,9 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain, if (*num_names == 0) goto do_cached; - (*sid_mem) = talloc(mem_ctx, sizeof(**sid_mem) * (*num_names)); - (*names) = talloc(mem_ctx, sizeof(**names) * (*num_names)); - (*name_types) = talloc(mem_ctx, sizeof(**name_types) * (*num_names)); + (*sid_mem) = TALLOC_ARRAY(mem_ctx, DOM_SID *, *num_names); + (*names) = TALLOC_ARRAY(mem_ctx, char *, *num_names); + (*name_types) = TALLOC_ARRAY(mem_ctx, uint32, *num_names); if (! (*sid_mem) || ! (*names) || ! (*name_types)) { smb_panic("lookup_groupmem out of memory"); diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c index c9aef2905f..1843ec188b 100644 --- a/source3/nsswitch/winbindd_cm.c +++ b/source3/nsswitch/winbindd_cm.c @@ -432,7 +432,7 @@ static BOOL add_one_dc_unique(TALLOC_CTX *mem_ctx, const char *domain_name, if (!NT_STATUS_IS_OK(check_negative_conn_cache(domain_name, dcname))) return False; - *dcs = talloc_realloc(mem_ctx, *dcs, ((*num)+1) * sizeof(**dcs)); + *dcs = TALLOC_REALLOC_ARRAY(mem_ctx, *dcs, struct dc_name_ip, (*num)+1); if (*dcs == NULL) return False; @@ -448,7 +448,7 @@ static BOOL add_string_to_array(TALLOC_CTX *mem_ctx, { char *dup_str = talloc_strdup(mem_ctx, str); - *array = talloc_realloc(mem_ctx, *array, ((*num)+1) * sizeof(**array)); + *array = TALLOC_REALLOC_ARRAY(mem_ctx, *array, char *, (*num)+1); if ((*array == NULL) || (dup_str == NULL)) return False; @@ -462,7 +462,7 @@ static BOOL add_sockaddr_to_array(TALLOC_CTX *mem_ctx, struct in_addr ip, uint16 port, struct sockaddr_in **addrs, int *num) { - *addrs = talloc_realloc(mem_ctx, *addrs, ((*num)+1) * sizeof(**addrs)); + *addrs = TALLOC_REALLOC_ARRAY(mem_ctx, *addrs, struct sockaddr_in, (*num)+1); if (*addrs == NULL) return False; @@ -753,7 +753,7 @@ static NTSTATUS new_cm_connection(struct winbindd_domain *domain, const char *pi struct winbindd_cm_conn *conn; NTSTATUS result; - if (!(conn = malloc(sizeof(*conn)))) + if (!(conn = SMB_MALLOC_P(struct winbindd_cm_conn))) return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(conn); diff --git a/source3/nsswitch/winbindd_dual.c b/source3/nsswitch/winbindd_dual.c index d4ec6e586d..587507ee29 100644 --- a/source3/nsswitch/winbindd_dual.c +++ b/source3/nsswitch/winbindd_dual.c @@ -117,7 +117,7 @@ void dual_send_request(struct winbindd_cli_state *state) if (!background_process) return; - list = malloc(sizeof(*list)); + list = SMB_MALLOC_P(struct dual_list); if (!list) return; list->next = NULL; diff --git a/source3/nsswitch/winbindd_group.c b/source3/nsswitch/winbindd_group.c index 7eb0585c37..4b49c1873e 100644 --- a/source3/nsswitch/winbindd_group.c +++ b/source3/nsswitch/winbindd_group.c @@ -47,7 +47,7 @@ static int gr_mem_buffer( char **buffer, char **members, int num_members ) for ( i=0; i<num_members; i++ ) len += strlen(members[i])+1; - *buffer = (char*)smb_xmalloc(len); + *buffer = SMB_XMALLOC_ARRAY(char, len); for ( i=0; i<num_members; i++ ) { snprintf( &(*buffer)[idx], len-idx, "%s,", members[i]); idx += strlen(members[i])+1; @@ -194,7 +194,7 @@ static BOOL fill_grent_mem(struct winbindd_domain *domain, /* Allocate buffer */ if (!buf && buf_len != 0) { - if (!(buf = malloc(buf_len))) { + if (!(buf = SMB_MALLOC(buf_len))) { DEBUG(1, ("out of memory\n")); result = False; goto done; @@ -457,8 +457,7 @@ enum winbindd_result winbindd_setgrent(struct winbindd_cli_state *state) } - if ((domain_state = (struct getent_state *) - malloc(sizeof(struct getent_state))) == NULL) { + if ((domain_state = SMB_MALLOC_P(struct getent_state)) == NULL) { DEBUG(1, ("winbindd_setgrent: malloc failed for domain_state!\n")); return WINBINDD_ERROR; } @@ -542,7 +541,7 @@ static BOOL get_sam_group_entries(struct getent_state *ent) /* Copy entries into return buffer */ if (num_entries) { - if ( !(name_list = malloc(sizeof(struct acct_info) * num_entries)) ) { + if ( !(name_list = SMB_MALLOC_ARRAY(struct acct_info, num_entries)) ) { DEBUG(0,("get_sam_group_entries: Failed to malloc memory for %d domain groups!\n", num_entries)); result = False; @@ -573,7 +572,7 @@ static BOOL get_sam_group_entries(struct getent_state *ent) /* Copy entries into return buffer */ if ( num_entries ) { - if ( !(tmp_name_list = Realloc( name_list, sizeof(struct acct_info) * (ent->num_sam_entries+num_entries))) ) + if ( !(tmp_name_list = SMB_REALLOC_ARRAY( name_list, struct acct_info, ent->num_sam_entries+num_entries)) ) { DEBUG(0,("get_sam_group_entries: Failed to realloc more memory for %d local groups!\n", num_entries)); @@ -625,8 +624,7 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state) num_groups = MIN(MAX_GETGRENT_GROUPS, state->request.data.num_entries); - if ((state->response.extra_data = - malloc(num_groups * sizeof(struct winbindd_gr))) == NULL) + if ((state->response.extra_data = SMB_MALLOC_ARRAY(struct winbindd_gr, num_groups)) == NULL) return WINBINDD_ERROR; memset(state->response.extra_data, '\0', @@ -746,9 +744,7 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state) if (result) { /* Append to group membership list */ - new_gr_mem_list = Realloc( - gr_mem_list, - gr_mem_list_len + gr_mem_len); + new_gr_mem_list = SMB_REALLOC( gr_mem_list, gr_mem_list_len + gr_mem_len); if (!new_gr_mem_list && (group_list[group_list_ndx].num_gr_mem != 0)) { DEBUG(0, ("out of memory\n")); @@ -799,7 +795,7 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state) if (group_list_ndx == 0) goto done; - new_extra_data = Realloc( + new_extra_data = SMB_REALLOC( state->response.extra_data, group_list_ndx * sizeof(struct winbindd_gr) + gr_mem_list_len); @@ -880,7 +876,7 @@ enum winbindd_result winbindd_list_groups(struct winbindd_cli_state *state) /* Allocate some memory for extra data. Note that we limit account names to sizeof(fstring) = 128 characters. */ - ted = Realloc(extra_data, sizeof(fstring) * total_entries); + ted = SMB_REALLOC(extra_data, sizeof(fstring) * total_entries); if (!ted) { DEBUG(0,("failed to enlarge buffer!\n")); @@ -1151,12 +1147,12 @@ static void add_sid_to_parray_unique(TALLOC_CTX *mem_ctx, const DOM_SID *sid, return; } - *sids = talloc_realloc(mem_ctx, *sids, sizeof(**sids) * (*num_sids+1)); + *sids = TALLOC_REALLOC_ARRAY(mem_ctx, *sids, DOM_SID *, *num_sids+1); if (*sids == NULL) return; - (*sids)[*num_sids] = talloc(mem_ctx, sizeof(DOM_SID)); + (*sids)[*num_sids] = TALLOC_P(mem_ctx, DOM_SID); sid_copy((*sids)[*num_sids], sid); *num_sids += 1; return; @@ -1259,7 +1255,7 @@ enum winbindd_result winbindd_getusersids(struct winbindd_cli_state *state) } /* build the reply */ - ret = malloc(ret_size); + ret = SMB_MALLOC(ret_size); if (!ret) goto done; ofs = 0; for (i = 0; i < num_groups; i++) { diff --git a/source3/nsswitch/winbindd_misc.c b/source3/nsswitch/winbindd_misc.c index 18478992f3..bb30a7029e 100644 --- a/source3/nsswitch/winbindd_misc.c +++ b/source3/nsswitch/winbindd_misc.c @@ -128,7 +128,7 @@ enum winbindd_result winbindd_list_trusted_domains(struct winbindd_cli_state /* Add domain to list */ total_entries++; - ted = Realloc(extra_data, sizeof(fstring) * + ted = SMB_REALLOC(extra_data, sizeof(fstring) * total_entries); if (!ted) { @@ -168,7 +168,7 @@ enum winbindd_result winbindd_show_sequence(struct winbindd_cli_state *state) state->request.domain_name[sizeof(state->request.domain_name)-1]='\0'; which_domain = state->request.domain_name; - extra_data = strdup(""); + extra_data = SMB_STRDUP(""); /* this makes for a very simple data format, and is easily parsable as well if that is ever needed */ @@ -296,7 +296,7 @@ enum winbindd_result winbindd_priv_pipe_dir(struct winbindd_cli_state *state) DEBUG(3, ("[%5lu]: request location of privileged pipe\n", (unsigned long)state->pid)); - state->response.extra_data = strdup(get_winbind_priv_pipe_dir()); + state->response.extra_data = SMB_STRDUP(get_winbind_priv_pipe_dir()); if (!state->response.extra_data) return WINBINDD_ERROR; diff --git a/source3/nsswitch/winbindd_pam.c b/source3/nsswitch/winbindd_pam.c index e13649afe1..f7d3ac5aa4 100644 --- a/source3/nsswitch/winbindd_pam.c +++ b/source3/nsswitch/winbindd_pam.c @@ -43,7 +43,7 @@ static NTSTATUS append_info3_as_ndr(TALLOC_CTX *mem_ctx, } size = prs_data_size(&ps); - state->response.extra_data = malloc(size); + state->response.extra_data = SMB_MALLOC(size); if (!state->response.extra_data) { prs_mem_free(&ps); return NT_STATUS_NO_MEMORY; @@ -78,7 +78,7 @@ static NTSTATUS check_info3_in_group(TALLOC_CTX *mem_ctx, return NT_STATUS_INVALID_PARAMETER; } - all_sids = talloc(mem_ctx, sizeof(DOM_SID) * num_all_sids); + all_sids = TALLOC_ARRAY(mem_ctx, DOM_SID, num_all_sids); if (!all_sids) return NT_STATUS_NO_MEMORY; @@ -363,7 +363,7 @@ done: if ( NT_STATUS_IS_OK(result) && (state->request.flags & WBFLAG_PAM_AFS_TOKEN) ) { - char *afsname = strdup(lp_afs_username_map()); + char *afsname = SMB_STRDUP(lp_afs_username_map()); char *cell; if (afsname == NULL) goto no_token; @@ -600,7 +600,7 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state) DEBUG(5, ("Setting unix username to [%s]\n", username_out)); - state->response.extra_data = strdup(username_out); + state->response.extra_data = SMB_STRDUP(username_out); if (!state->response.extra_data) { result = NT_STATUS_NO_MEMORY; goto done; diff --git a/source3/nsswitch/winbindd_passdb.c b/source3/nsswitch/winbindd_passdb.c index 3adb81caa3..a208186b5f 100644 --- a/source3/nsswitch/winbindd_passdb.c +++ b/source3/nsswitch/winbindd_passdb.c @@ -217,8 +217,7 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain, return NT_STATUS_OK; } - talloced_info = (struct acct_info *) - talloc_memdup(mem_ctx, *info, + talloced_info = (struct acct_info *)TALLOC_MEMDUP(mem_ctx, *info, *num_entries * sizeof(struct acct_info)); SAFE_FREE(*info); @@ -332,15 +331,12 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain, nt_status = secrets_get_trusted_domains(mem_ctx, &enum_ctx, 1, &num_sec_domains, &domains); - *names = talloc_realloc(mem_ctx, *names, - sizeof(*names) * - (num_sec_domains + *num_domains)); - *alt_names = talloc_realloc(mem_ctx, *alt_names, - sizeof(*alt_names) * - (num_sec_domains + *num_domains)); - *dom_sids = talloc_realloc(mem_ctx, *dom_sids, - sizeof(**dom_sids) * - (num_sec_domains + *num_domains)); + *names = TALLOC_REALLOC_ARRAY(mem_ctx, *names, char *, + num_sec_domains + *num_domains); + *alt_names = TALLOC_REALLOC_ARRAY(mem_ctx, *alt_names, char *, + num_sec_domains + *num_domains); + *dom_sids = TALLOC_REALLOC_ARRAY(mem_ctx, *dom_sids, DOM_SID, + num_sec_domains + *num_domains); for (i=0; i< num_sec_domains; i++) { if (pull_ucs2_talloc(mem_ctx, &(*names)[*num_domains], diff --git a/source3/nsswitch/winbindd_rpc.c b/source3/nsswitch/winbindd_rpc.c index ba24749fbe..de7f2ff76f 100644 --- a/source3/nsswitch/winbindd_rpc.c +++ b/source3/nsswitch/winbindd_rpc.c @@ -98,8 +98,7 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, *num_entries += num_dom_users; - *info = talloc_realloc( mem_ctx, *info, - (*num_entries) * sizeof(WINBIND_USERINFO)); + *info = TALLOC_REALLOC_ARRAY( mem_ctx, *info, WINBIND_USERINFO, *num_entries); if (!(*info)) { result = NT_STATUS_NO_MEMORY; @@ -192,8 +191,7 @@ static NTSTATUS enum_dom_groups(struct winbindd_domain *domain, break; } - (*info) = talloc_realloc(mem_ctx, *info, - sizeof(**info) * ((*num_entries) + count)); + (*info) = TALLOC_REALLOC_ARRAY(mem_ctx, *info, struct acct_info, (*num_entries) + count); if (! *info) { talloc_destroy(mem_ctx2); cli_samr_close(hnd->cli, mem_ctx, &dom_pol); @@ -255,8 +253,7 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain, break; } - (*info) = talloc_realloc(mem_ctx, *info, - sizeof(**info) * ((*num_entries) + count)); + (*info) = TALLOC_REALLOC_ARRAY(mem_ctx, *info, struct acct_info, (*num_entries) + count); if (! *info) { talloc_destroy(mem_ctx2); cli_samr_close(hnd->cli, mem_ctx, &dom_pol); @@ -491,7 +488,7 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain, *num_groups = user->num_groups; - (*user_grpsids) = talloc(mem_ctx, sizeof(DOM_SID*) * (*num_groups)); + (*user_grpsids) = TALLOC_ARRAY(mem_ctx, DOM_SID*, *num_groups); for (i=0;i<(*num_groups);i++) { (*user_grpsids)[i] = rid_to_talloced_sid(domain, mem_ctx, user->gids[i].g_rid); } @@ -543,7 +540,7 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain, if (!NT_STATUS_IS_OK(result) || (*num_groups) == 0) goto done; - (*user_grpsids) = talloc(mem_ctx, sizeof(DOM_SID*) * (*num_groups)); + (*user_grpsids) = TALLOC_ARRAY(mem_ctx, DOM_SID *, *num_groups); if (!(*user_grpsids)) { result = NT_STATUS_NO_MEMORY; goto done; @@ -643,9 +640,9 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain, #define MAX_LOOKUP_RIDS 900 - *names = talloc_zero(mem_ctx, *num_names * sizeof(char *)); - *name_types = talloc_zero(mem_ctx, *num_names * sizeof(uint32)); - *sid_mem = talloc_zero(mem_ctx, *num_names * sizeof(DOM_SID *)); + *names = TALLOC_ZERO_ARRAY(mem_ctx, char *, *num_names); + *name_types = TALLOC_ZERO_ARRAY(mem_ctx, uint32, *num_names); + *sid_mem = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID *, *num_names); for (j=0;j<(*num_names);j++) { (*sid_mem)[j] = rid_to_talloced_sid(domain, mem_ctx, (rid_mem)[j]); diff --git a/source3/nsswitch/winbindd_user.c b/source3/nsswitch/winbindd_user.c index 249b9ccd8e..fc3fe0f963 100644 --- a/source3/nsswitch/winbindd_user.c +++ b/source3/nsswitch/winbindd_user.c @@ -351,8 +351,7 @@ enum winbindd_result winbindd_setpwent(struct winbindd_cli_state *state) /* Create a state record for this domain */ - if ((domain_state = (struct getent_state *) - malloc(sizeof(struct getent_state))) == NULL) + if ((domain_state = SMB_MALLOC_P(struct getent_state)) == NULL) return WINBINDD_ERROR; ZERO_STRUCTP(domain_state); @@ -429,10 +428,7 @@ static BOOL get_sam_user_entries(struct getent_state *ent) if (num_entries) { struct getpwent_user *tnl; - tnl = (struct getpwent_user *)Realloc(name_list, - sizeof(struct getpwent_user) * - (ent->num_sam_entries + - num_entries)); + tnl = SMB_REALLOC_ARRAY(name_list, struct getpwent_user, ent->num_sam_entries + num_entries); if (!tnl) { DEBUG(0,("get_sam_user_entries realloc failed.\n")); @@ -498,8 +494,7 @@ enum winbindd_result winbindd_getpwent(struct winbindd_cli_state *state) num_users = MIN(MAX_GETPWENT_USERS, state->request.data.num_entries); - if ((state->response.extra_data = - malloc(num_users * sizeof(struct winbindd_pw))) == NULL) + if ((state->response.extra_data = SMB_MALLOC_ARRAY(struct winbindd_pw, num_users)) == NULL) return WINBINDD_ERROR; memset(state->response.extra_data, 0, num_users * @@ -624,7 +619,7 @@ enum winbindd_result winbindd_list_users(struct winbindd_cli_state *state) /* Allocate some memory for extra data */ total_entries += num_entries; - ted = Realloc(extra_data, sizeof(fstring) * total_entries); + ted = SMB_REALLOC(extra_data, sizeof(fstring) * total_entries); if (!ted) { DEBUG(0,("failed to enlarge buffer!\n")); diff --git a/source3/nsswitch/winbindd_util.c b/source3/nsswitch/winbindd_util.c index a96f652c61..7cbcba1245 100644 --- a/source3/nsswitch/winbindd_util.c +++ b/source3/nsswitch/winbindd_util.c @@ -139,7 +139,7 @@ static struct winbindd_domain *add_trusted_domain(const char *domain_name, const /* Create new domain entry */ - if ((domain = (struct winbindd_domain *)malloc(sizeof(*domain))) == NULL) + if ((domain = SMB_MALLOC_P(struct winbindd_domain)) == NULL) return NULL; /* Fill in fields */ @@ -777,7 +777,7 @@ DOM_SID *rid_to_talloced_sid(struct winbindd_domain *domain, uint32 rid) { DOM_SID *sid; - sid = talloc(mem_ctx, sizeof(*sid)); + sid = TALLOC_P(mem_ctx, DOM_SID); if (!sid) { smb_panic("rid_to_to_talloced_sid: talloc for DOM_SID failed!\n"); } diff --git a/source3/nsswitch/winbindd_wins.c b/source3/nsswitch/winbindd_wins.c index 107c9d264c..f199ebcb43 100644 --- a/source3/nsswitch/winbindd_wins.c +++ b/source3/nsswitch/winbindd_wins.c @@ -97,7 +97,7 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count) if (resolve_wins(name,0x20,&ret,count)) { if ( count == 0 ) return NULL; - if ( (return_ip = (struct in_addr *)malloc((*count)*sizeof(struct in_addr))) == NULL ) { + if ( (return_ip = SMB_MALLOC_ARRAY(struct in_addr, *count)) == NULL ) { free( ret ); return NULL; } diff --git a/source3/nsswitch/wins.c b/source3/nsswitch/wins.c index a1c4f4deec..8d26fc5297 100644 --- a/source3/nsswitch/wins.c +++ b/source3/nsswitch/wins.c @@ -101,7 +101,7 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count) /* always try with wins first */ if (resolve_wins(name,0x00,&address,count)) { - if ( (ret = (struct in_addr *)malloc(sizeof(struct in_addr))) == NULL ) { + if ( (ret = SMB_MALLOC_P(struct in_addr)) == NULL ) { free( address ); return NULL; } |