diff options
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net.c | 20 | ||||
-rw-r--r-- | source3/utils/net_ads.c | 6 | ||||
-rw-r--r-- | source3/utils/net_cache.c | 2 | ||||
-rw-r--r-- | source3/utils/net_idmap.c | 2 | ||||
-rw-r--r-- | source3/utils/net_rap.c | 2 | ||||
-rw-r--r-- | source3/utils/net_rpc.c | 25 | ||||
-rw-r--r-- | source3/utils/net_rpc_join.c | 2 | ||||
-rw-r--r-- | source3/utils/net_rpc_printer.c | 8 | ||||
-rw-r--r-- | source3/utils/net_rpc_samsync.c | 2 | ||||
-rw-r--r-- | source3/utils/net_status.c | 3 | ||||
-rw-r--r-- | source3/utils/ntlm_auth.c | 28 | ||||
-rw-r--r-- | source3/utils/pdbedit.c | 4 | ||||
-rw-r--r-- | source3/utils/smbcacls.c | 6 | ||||
-rw-r--r-- | source3/utils/smbtree.c | 2 |
14 files changed, 53 insertions, 59 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c index 784612fc71..251e94db90 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -144,7 +144,7 @@ NTSTATUS connect_to_service(struct cli_state **c, struct in_addr *server_ip, if (!opt_password && !opt_machine_pass) { char *pass = getpass("Password:"); if (pass) { - opt_password = strdup(pass); + opt_password = SMB_STRDUP(pass); } } @@ -221,11 +221,11 @@ NTSTATUS connect_to_ipc_anonymous(struct cli_state **c, NTSTATUS connect_pipe(struct cli_state **cli_dst, int pipe_num, BOOL *got_pipe) { NTSTATUS nt_status; - char *server_name = strdup("127.0.0.1"); + char *server_name = SMB_STRDUP("127.0.0.1"); struct cli_state *cli_tmp = NULL; if (opt_destination) - server_name = strdup(opt_destination); + server_name = SMB_STRDUP(opt_destination); /* make a connection to a named pipe */ nt_status = connect_to_ipc(&cli_tmp, NULL, server_name); @@ -270,13 +270,13 @@ BOOL net_find_server(unsigned flags, struct in_addr *server_ip, char **server_na { if (opt_host) { - *server_name = strdup(opt_host); + *server_name = SMB_STRDUP(opt_host); } if (opt_have_ip) { *server_ip = opt_dest_ip; if (!*server_name) { - *server_name = strdup(inet_ntoa(opt_dest_ip)); + *server_name = SMB_STRDUP(inet_ntoa(opt_dest_ip)); } } else if (*server_name) { /* resolve the IP address */ @@ -296,7 +296,7 @@ BOOL net_find_server(unsigned flags, struct in_addr *server_ip, char **server_na if ( !name_status_find(opt_target_workgroup, 0x1b, 0x20, pdc_ip, dc_name) ) return False; - *server_name = strdup(dc_name); + *server_name = SMB_STRDUP(dc_name); *server_ip = pdc_ip; } @@ -309,7 +309,7 @@ BOOL net_find_server(unsigned flags, struct in_addr *server_ip, char **server_na } else { *server_ip = msbrow_ip; } - *server_name = strdup(inet_ntoa(opt_dest_ip)); + *server_name = SMB_STRDUP(inet_ntoa(opt_dest_ip)); } else if (flags & NET_FLAGS_MASTER) { struct in_addr brow_ips; if (!resolve_name(opt_target_workgroup, &brow_ips, 0x1D)) { @@ -319,11 +319,11 @@ BOOL net_find_server(unsigned flags, struct in_addr *server_ip, char **server_na } else { *server_ip = brow_ips; } - *server_name = strdup(inet_ntoa(opt_dest_ip)); + *server_name = SMB_STRDUP(inet_ntoa(opt_dest_ip)); } else if (!(flags & NET_FLAGS_LOCALHOST_DEFAULT_INSANE)) { extern struct in_addr loopback_ip; *server_ip = loopback_ip; - *server_name = strdup("127.0.0.1"); + *server_name = SMB_STRDUP("127.0.0.1"); } if (!server_name || !*server_name) { @@ -786,7 +786,7 @@ static struct functable net_func[] = { break; case 'U': opt_user_specified = True; - opt_user_name = strdup(opt_user_name); + opt_user_name = SMB_STRDUP(opt_user_name); p = strchr(opt_user_name,'%'); if (p) { *p = 0; diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 9efa45e58f..72e8f70a7d 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -259,10 +259,10 @@ static BOOL usergrp_display(char *field, void **values, void *data_area) if (!values) /* must be new field, indicate string field */ return True; if (StrCaseCmp(field, "sAMAccountName") == 0) { - disp_fields[0] = strdup((char *) values[0]); + disp_fields[0] = SMB_STRDUP((char *) values[0]); } if (StrCaseCmp(field, "description") == 0) - disp_fields[1] = strdup((char *) values[0]); + disp_fields[1] = SMB_STRDUP((char *) values[0]); return True; } @@ -718,7 +718,7 @@ int net_ads_join(int argc, const char **argv) } tmp_password = generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); - password = strdup(tmp_password); + password = SMB_STRDUP(tmp_password); if (!(ads = ads_startup())) { return -1; diff --git a/source3/utils/net_cache.c b/source3/utils/net_cache.c index a955916458..6bbab1c817 100644 --- a/source3/utils/net_cache.c +++ b/source3/utils/net_cache.c @@ -101,7 +101,7 @@ static time_t parse_timeout(const char* timeout_str) /* number detection */ len = (sign) ? strlen(&timeout_str[number_begin]) : len; number_end = (unit) ? len - 1 : len; - number = strndup(&timeout_str[number_begin], number_end); + number = SMB_STRNDUP(&timeout_str[number_begin], number_end); /* calculate actual timeout value */ timeout = (time_t)atoi(number); diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c index 35892e8b52..b4f4cdb0a8 100644 --- a/source3/utils/net_idmap.c +++ b/source3/utils/net_idmap.c @@ -126,7 +126,7 @@ static NTSTATUS net_idmap_fixup_hwm(void) return NT_STATUS_UNSUCCESSFUL; } - tdbfile = strdup(lock_path("winbindd_idmap.tdb")); + tdbfile = SMB_STRDUP(lock_path("winbindd_idmap.tdb")); if (!tdbfile) { DEBUG(0, ("idmap_init: out of memory!\n")); return NT_STATUS_NO_MEMORY; diff --git a/source3/utils/net_rap.c b/source3/utils/net_rap.c index cae0a7f7da..6e8f0d088d 100644 --- a/source3/utils/net_rap.c +++ b/source3/utils/net_rap.c @@ -198,7 +198,7 @@ static int rap_share_add(int argc, const char **argv) if (!(cli = net_make_ipc_connection(0))) return -1; - sharename = strdup(argv[0]); + sharename = SMB_STRDUP(argv[0]); p = strchr(sharename, '='); *p = 0; strlcpy(sinfo.share_name, sharename, sizeof(sinfo.share_name)); diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index a488affe26..4c5544aa97 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -884,7 +884,7 @@ rpc_user_info_internals(const DOM_SID *domain_sid, const char *domain_name, /* Look up rids */ - rids = (uint32 *)talloc(mem_ctx, sizeof(uint32) * num_rids); + rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids); for (i = 0; i < num_rids; i++) rids[i] = user_gids[i].g_rid; @@ -2805,7 +2805,7 @@ rpc_share_migrate_files_internals(const DOM_SID *domain_sid, const char *domain_ pstring mask; char *dst = NULL; - dst = strdup(opt_destination?opt_destination:"127.0.0.1"); + dst = SMB_STRDUP(opt_destination?opt_destination:"127.0.0.1"); init_enum_hnd(&hnd, 0); @@ -2989,7 +2989,7 @@ static struct full_alias *server_aliases; static void push_alias(TALLOC_CTX *mem_ctx, struct full_alias *alias) { if (server_aliases == NULL) - server_aliases = malloc(100 * sizeof(struct full_alias)); + server_aliases = SMB_MALLOC_ARRAY(struct full_alias, 100); server_aliases[num_server_aliases] = *alias; num_server_aliases += 1; @@ -3053,8 +3053,7 @@ rpc_fetch_domain_aliases(struct cli_state *cli, TALLOC_CTX *mem_ctx, alias.members = NULL; if (alias.num_members > 0) { - alias.members = malloc(alias.num_members * - sizeof(DOM_SID)); + alias.members = SMB_MALLOC_ARRAY(DOM_SID, alias.num_members); for (j = 0; j < alias.num_members; j++) sid_copy(&alias.members[j], @@ -3183,7 +3182,7 @@ static void init_user_token(NT_USER_TOKEN *token, DOM_SID *user_sid) token->num_sids = 4; - token->user_sids = malloc(4 * sizeof(DOM_SID)); + token->user_sids = SMB_MALLOC_ARRAY(DOM_SID, 4); token->user_sids[0] = *user_sid; sid_copy(&token->user_sids[1], &global_sid_World); @@ -3212,8 +3211,7 @@ static void add_sid_to_token(NT_USER_TOKEN *token, DOM_SID *sid) if (is_sid_in_token(token, sid)) return; - token->user_sids = Realloc(token->user_sids, - (token->num_sids+1) * sizeof(DOM_SID)); + token->user_sids = SMB_REALLOC_ARRAY(token->user_sids, DOM_SID, token->num_sids+1); sid_copy(&token->user_sids[token->num_sids], sid); @@ -3392,7 +3390,7 @@ static BOOL get_user_tokens(int *num_tokens, struct user_token **user_tokens) *num_tokens += 1; } - result = malloc(*num_tokens * sizeof(struct user_token)); + result = SMB_MALLOC_ARRAY(struct user_token, *num_tokens); if (result == NULL) { DEBUG(1, ("Could not malloc sid array\n")); @@ -3467,9 +3465,7 @@ static BOOL get_user_tokens_from_file(FILE *f, /* And a new user... */ *num_tokens += 1; - *tokens = Realloc(*tokens, - *num_tokens * - sizeof(struct user_token)); + *tokens = SMB_REALLOC_ARRAY(*tokens, struct user_token, *num_tokens); if (*tokens == NULL) { DEBUG(0, ("Could not realloc tokens\n")); return False; @@ -3587,9 +3583,8 @@ static void collect_share(const char *name, uint32 m, return; share_list->num_shares += 1; - share_list->shares = Realloc(share_list->shares, - share_list->num_shares * sizeof(char *)); - share_list->shares[share_list->num_shares-1] = strdup(name); + share_list->shares = SMB_REALLOC_ARRAY(share_list->shares, char *, share_list->num_shares); + share_list->shares[share_list->num_shares-1] = SMB_STRDUP(name); } static void rpc_share_userlist_usage(void) diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c index cb8a5ee4d4..79c632f831 100644 --- a/source3/utils/net_rpc_join.c +++ b/source3/utils/net_rpc_join.c @@ -258,7 +258,7 @@ int net_rpc_join_newstyle(int argc, const char **argv) { char *str; str = generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); - clear_trust_password = strdup(str); + clear_trust_password = SMB_STRDUP(str); E_md4hash(clear_trust_password, md4_trust_password); } diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 25f3ab5184..456a29287f 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -501,7 +501,7 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx, } /* allocate memory */ - if (!(data = (char *)malloc(read_size))) { + if (!(data = (char *)SMB_MALLOC(read_size))) { d_printf("malloc fail for size %d\n", read_size); nt_status = NT_STATUS_NO_MEMORY; goto out; @@ -1153,7 +1153,7 @@ get_printer_info(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* argument given, get a single printer by name */ - sharename = strdup(argv[0]); + sharename = SMB_STRDUP(argv[0]); if (!net_spoolss_open_printer_ex(cli, mem_ctx, sharename, MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd)) @@ -2299,7 +2299,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const } /* copy devmode (info level 2) */ - ctr_dst.printers_2->devmode = talloc_memdup(mem_ctx, + ctr_dst.printers_2->devmode = TALLOC_MEMDUP(mem_ctx, ctr_enum.printers_2[i].devmode, sizeof(DEVICEMODE)); /* do not copy security descriptor (we have another command for that) */ @@ -2461,7 +2461,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const value.type = REG_SZ; value.size = data.uni_str_len * 2; - value.data_p = talloc_memdup(mem_ctx, data.buffer, value.size); + value.data_p = TALLOC_MEMDUP(mem_ctx, data.buffer, value.size); if (opt_verbose) display_reg_value(subkey, value); diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 2e7c053ac3..b31087927a 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -595,7 +595,7 @@ fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) return NT_STATUS_NO_MEMORY; } - nt_members = talloc_zero(t, sizeof(char *) * delta->num_members); + nt_members = TALLOC_ZERO_ARRAY(t, char *, delta->num_members); for (i=0; i<delta->num_members; i++) { NTSTATUS nt_status; diff --git a/source3/utils/net_status.c b/source3/utils/net_status.c index 21e6bffb2c..d584597273 100644 --- a/source3/utils/net_status.c +++ b/source3/utils/net_status.c @@ -129,8 +129,7 @@ static int collect_pid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, return 0; ids->num_entries += 1; - ids->entries = Realloc(ids->entries, - sizeof(struct sessionid) * ids->num_entries); + ids->entries = SMB_REALLOC_ARRAY(ids->entries, struct sessionid, ids->num_entries); ids->entries[ids->num_entries-1] = sessionid; return 0; diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index 3d51523831..3d55c37355 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -238,7 +238,7 @@ static BOOL get_require_membership_sid(void) { return False; } - require_membership_of_sid = strdup(response.data.sid.sid); + require_membership_of_sid = SMB_STRDUP(response.data.sid.sid); if (require_membership_of_sid) return True; @@ -378,7 +378,7 @@ NTSTATUS contact_winbind_auth_crap(const char *username, } if (flags & WBFLAG_PAM_UNIX_NAME) { - *unix_name = strdup((char *)response.extra_data); + *unix_name = SMB_STRDUP((char *)response.extra_data); if (!*unix_name) { free_response(&response); return NT_STATUS_NO_MEMORY; @@ -552,7 +552,7 @@ static void manage_squid_ntlmssp_request(enum stdio_helper_mode stdio_helper_mod if ((strncmp(buf, "PW ", 3) == 0)) { /* The calling application wants us to use a local password (rather than winbindd) */ - opt_password = strndup((const char *)request.data, request.length); + opt_password = SMB_STRNDUP((const char *)request.data, request.length); if (opt_password == NULL) { DEBUG(1, ("Out of memory\n")); @@ -634,7 +634,7 @@ static void manage_client_ntlmssp_request(enum stdio_helper_mode stdio_helper_mo if (strncmp(buf, "PW ", 3) == 0) { /* We asked for a password and obviously got it :-) */ - opt_password = strndup((const char *)request.data, request.length); + opt_password = SMB_STRNDUP((const char *)request.data, request.length); if (opt_password == NULL) { DEBUG(1, ("Out of memory\n")); @@ -753,7 +753,7 @@ static void offer_gss_spnego_mechs(void) { /* Server negTokenInit (mech offerings) */ spnego.type = SPNEGO_NEG_TOKEN_INIT; - spnego.negTokenInit.mechTypes = smb_xmalloc(sizeof(char *) * 3); + spnego.negTokenInit.mechTypes = SMB_XMALLOC_ARRAY(char *, 3); #ifdef HAVE_KRB5 spnego.negTokenInit.mechTypes[0] = smb_xstrdup(OID_KERBEROS5_OLD); spnego.negTokenInit.mechTypes[1] = smb_xstrdup(OID_NTLMSSP); @@ -883,7 +883,7 @@ static void manage_gss_spnego_request(enum stdio_helper_mode stdio_helper_mode, request.negTokenInit.mechToken.length); response.type = SPNEGO_NEG_TOKEN_TARG; - response.negTokenTarg.supportedMech = strdup(OID_NTLMSSP); + response.negTokenTarg.supportedMech = SMB_STRDUP(OID_NTLMSSP); response.negTokenTarg.mechListMIC = data_blob(NULL, 0); status = ntlmssp_update(ntlmssp_state, @@ -906,7 +906,7 @@ static void manage_gss_spnego_request(enum stdio_helper_mode stdio_helper_mode, } response.type = SPNEGO_NEG_TOKEN_TARG; - response.negTokenTarg.supportedMech = strdup(OID_KERBEROS5_OLD); + response.negTokenTarg.supportedMech = SMB_STRDUP(OID_KERBEROS5_OLD); response.negTokenTarg.mechListMIC = data_blob(NULL, 0); response.negTokenTarg.responseToken = data_blob(NULL, 0); @@ -930,8 +930,8 @@ static void manage_gss_spnego_request(enum stdio_helper_mode stdio_helper_mode, } *domain++ = '\0'; - domain = strdup(domain); - user = strdup(principal); + domain = SMB_STRDUP(domain); + user = SMB_STRDUP(principal); data_blob_free(&ap_rep); data_blob_free(&auth_data); @@ -964,12 +964,12 @@ static void manage_gss_spnego_request(enum stdio_helper_mode stdio_helper_mode, &response.negTokenTarg.responseToken); response.type = SPNEGO_NEG_TOKEN_TARG; - response.negTokenTarg.supportedMech = strdup(OID_NTLMSSP); + response.negTokenTarg.supportedMech = SMB_STRDUP(OID_NTLMSSP); response.negTokenTarg.mechListMIC = data_blob(NULL, 0); if (NT_STATUS_IS_OK(status)) { - user = strdup(ntlmssp_state->user); - domain = strdup(ntlmssp_state->domain); + user = SMB_STRDUP(ntlmssp_state->user); + domain = SMB_STRDUP(ntlmssp_state->domain); ntlmssp_end(&ntlmssp_state); } } @@ -1155,7 +1155,7 @@ static BOOL manage_client_krb5_init(SPNEGO_DATA spnego) return False; } - principal = malloc(spnego.negTokenInit.mechListMIC.length+1); + principal = SMB_MALLOC(spnego.negTokenInit.mechListMIC.length+1); if (principal == NULL) { DEBUG(1, ("Could not malloc principal\n")); @@ -1266,7 +1266,7 @@ static void manage_gss_spnego_client_request(enum stdio_helper_mode stdio_helper /* We asked for a password and obviously got it :-) */ - opt_password = strndup((const char *)request.data, request.length); + opt_password = SMB_STRNDUP((const char *)request.data, request.length); if (opt_password == NULL) { DEBUG(1, ("Out of memory\n")); diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 1eb6a135c5..2e8d0d6d96 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -429,10 +429,10 @@ static int new_user (struct pdb_context *in, const char *username, } staticpass = getpass("new password:"); - password1 = strdup(staticpass); + password1 = SMB_STRDUP(staticpass); memset(staticpass, 0, strlen(staticpass)); staticpass = getpass("retype new password:"); - password2 = strdup(staticpass); + password2 = SMB_STRDUP(staticpass); memset(staticpass, 0, strlen(staticpass)); if (strcmp (password1, password2)) { fprintf (stderr, "Passwords does not match!\n"); diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index b12bf4d35d..048ec8dc3e 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -325,7 +325,7 @@ static BOOL add_ace(SEC_ACL **the_acl, SEC_ACE *ace) return True; } - aces = calloc(1+(*the_acl)->num_aces,sizeof(SEC_ACE)); + aces = SMB_CALLOC_ARRAY(SEC_ACE, 1+(*the_acl)->num_aces); memcpy(aces, (*the_acl)->ace, (*the_acl)->num_aces * sizeof(SEC_ACE)); memcpy(aces+(*the_acl)->num_aces, ace, sizeof(SEC_ACE)); new = make_sec_acl(ctx,(*the_acl)->revision,1+(*the_acl)->num_aces, aces); @@ -353,7 +353,7 @@ static SEC_DESC *sec_desc_parse(char *str) } if (strncmp(tok,"OWNER:", 6) == 0) { - owner_sid = (DOM_SID *)calloc(1, sizeof(DOM_SID)); + owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); if (!owner_sid || !StringToSid(owner_sid, tok+6)) { printf("Failed to parse owner sid\n"); @@ -363,7 +363,7 @@ static SEC_DESC *sec_desc_parse(char *str) } if (strncmp(tok,"GROUP:", 6) == 0) { - grp_sid = (DOM_SID *)calloc(1, sizeof(DOM_SID)); + grp_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); if (!grp_sid || !StringToSid(grp_sid, tok+6)) { printf("Failed to parse group sid\n"); diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index cbe1bd448f..00f6a74f2f 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -51,7 +51,7 @@ static void add_name(const char *machine_name, uint32 server_type, struct name_list **name_list = (struct name_list **)state; struct name_list *new_name; - new_name = (struct name_list *)malloc(sizeof(struct name_list)); + new_name = SMB_MALLOC_P(struct name_list); if (!new_name) return; |