diff options
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/asn1.c | 10 | ||||
-rw-r--r-- | source3/libsmb/clientgen.c | 6 | ||||
-rw-r--r-- | source3/libsmb/clifile.c | 6 | ||||
-rw-r--r-- | source3/libsmb/clilist.c | 4 | ||||
-rw-r--r-- | source3/libsmb/cliquota.c | 8 | ||||
-rw-r--r-- | source3/libsmb/clireadwrite.c | 4 | ||||
-rw-r--r-- | source3/libsmb/clitrans.c | 8 | ||||
-rw-r--r-- | source3/libsmb/conncache.c | 3 | ||||
-rw-r--r-- | source3/libsmb/libsmb_cache.c | 10 | ||||
-rw-r--r-- | source3/libsmb/libsmb_compat.c | 2 | ||||
-rw-r--r-- | source3/libsmb/libsmbclient.c | 46 | ||||
-rw-r--r-- | source3/libsmb/namequery.c | 21 | ||||
-rw-r--r-- | source3/libsmb/nmblib.c | 17 | ||||
-rw-r--r-- | source3/libsmb/ntlmssp.c | 4 | ||||
-rw-r--r-- | source3/libsmb/samlogon_cache.c | 2 | ||||
-rw-r--r-- | source3/libsmb/smb_signing.c | 10 | ||||
-rw-r--r-- | source3/libsmb/spnego.c | 5 |
17 files changed, 80 insertions, 86 deletions
diff --git a/source3/libsmb/asn1.c b/source3/libsmb/asn1.c index 2807b4e1d3e..6db12fc6125 100644 --- a/source3/libsmb/asn1.c +++ b/source3/libsmb/asn1.c @@ -32,7 +32,7 @@ BOOL asn1_write(ASN1_DATA *data, const void *p, int len) if (data->has_error) return False; if (data->length < data->ofs+len) { uint8 *newp; - newp = Realloc(data->data, data->ofs+len); + newp = SMB_REALLOC(data->data, data->ofs+len); if (!newp) { SAFE_FREE(data->data); data->has_error = True; @@ -58,7 +58,7 @@ BOOL asn1_push_tag(ASN1_DATA *data, uint8 tag) struct nesting *nesting; asn1_write_uint8(data, tag); - nesting = (struct nesting *)malloc(sizeof(struct nesting)); + nesting = SMB_MALLOC_P(struct nesting); if (!nesting) { data->has_error = True; return False; @@ -255,7 +255,7 @@ BOOL asn1_start_tag(ASN1_DATA *data, uint8 tag) data->has_error = True; return False; } - nesting = (struct nesting *)malloc(sizeof(struct nesting)); + nesting = SMB_MALLOC_P(struct nesting); if (!nesting) { data->has_error = True; return False; @@ -350,7 +350,7 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) asn1_end_tag(data); - *OID = strdup(oid_str); + *OID = SMB_STRDUP(oid_str); return !data->has_error; } @@ -380,7 +380,7 @@ BOOL asn1_read_GeneralString(ASN1_DATA *data, char **s) data->has_error = True; return False; } - *s = malloc(len+1); + *s = SMB_MALLOC(len+1); if (! *s) { data->has_error = True; return False; diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 974ebf91f5c..682e0d8b85a 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -253,7 +253,7 @@ struct cli_state *cli_initialise(struct cli_state *cli) } if (!cli) { - cli = (struct cli_state *)malloc(sizeof(*cli)); + cli = SMB_MALLOC_P(struct cli_state); if (!cli) return NULL; ZERO_STRUCTP(cli); @@ -275,8 +275,8 @@ struct cli_state *cli_initialise(struct cli_state *cli) cli->timeout = 20000; /* Timeout is in milliseconds. */ cli->bufsize = CLI_BUFFER_SIZE+4; cli->max_xmit = cli->bufsize; - cli->outbuf = (char *)malloc(cli->bufsize+SAFETY_MARGIN); - cli->inbuf = (char *)malloc(cli->bufsize+SAFETY_MARGIN); + cli->outbuf = (char *)SMB_MALLOC(cli->bufsize+SAFETY_MARGIN); + cli->inbuf = (char *)SMB_MALLOC(cli->bufsize+SAFETY_MARGIN); cli->oplock_handler = cli_oplock_ack; cli->case_sensitive = False; diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 7816ed0fc6e..9d20ed3adcd 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -1351,7 +1351,7 @@ int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path) pstring path2; clistr_pull(cli, path2, p, sizeof(path2), len, STR_ASCII); - *tmp_path = strdup(path2); + *tmp_path = SMB_STRDUP(path2); } return SVAL(cli->inbuf,smb_vwv0); @@ -1402,7 +1402,7 @@ static BOOL cli_set_ea(struct cli_state *cli, uint16 setup, char *param, unsigne size_t ea_namelen = strlen(ea_name); data_len = 4 + 4 + ea_namelen + 1 + ea_len; - data = malloc(data_len); + data = SMB_MALLOC(data_len); if (!data) { return False; } @@ -1558,7 +1558,7 @@ static BOOL cli_get_ea_list(struct cli_state *cli, goto out; } - ea_list = (struct ea_struct *)talloc(ctx, num_eas*sizeof(struct ea_struct)); + ea_list = TALLOC_ARRAY(ctx, struct ea_struct, num_eas); if (!ea_list) { goto out; } diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c index ab157d48e96..8ab5854c8fb 100644 --- a/source3/libsmb/clilist.c +++ b/source3/libsmb/clilist.c @@ -282,7 +282,7 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, } /* and add them to the dirlist pool */ - tdl = Realloc(dirlist,dirlist_len + data_len); + tdl = SMB_REALLOC(dirlist,dirlist_len + data_len); if (!tdl) { DEBUG(0,("cli_list_new: Failed to expand dirlist\n")); @@ -413,7 +413,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, first = False; - tdl = Realloc(dirlist,(num_received + received)*DIR_STRUCT_SIZE); + tdl = SMB_REALLOC(dirlist,(num_received + received)*DIR_STRUCT_SIZE); if (!tdl) { DEBUG(0,("cli_list_old: failed to expand dirlist")); diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index af8b4422b78..25c36c214fc 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -321,12 +321,12 @@ BOOL cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST goto cleanup; } - if ((tmp_list_ent=(SMB_NTQUOTA_LIST *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_LIST)))==NULL) { + if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) { DEBUG(0,("talloc_zero() failed\n")); return (-1); } - if ((tmp_list_ent->quotas=(SMB_NTQUOTA_STRUCT *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_STRUCT)))==NULL) { + if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) { DEBUG(0,("talloc_zero() failed\n")); return (-1); } @@ -379,13 +379,13 @@ BOOL cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST goto cleanup; } - if ((tmp_list_ent=(SMB_NTQUOTA_LIST *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_LIST)))==NULL) { + if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) { DEBUG(0,("talloc_zero() failed\n")); talloc_destroy(mem_ctx); goto cleanup; } - if ((tmp_list_ent->quotas=(SMB_NTQUOTA_STRUCT *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_STRUCT)))==NULL) { + if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) { DEBUG(0,("talloc_zero() failed\n")); talloc_destroy(mem_ctx); goto cleanup; diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index d1a23d36c8b..32230988204 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -256,8 +256,8 @@ static BOOL cli_issue_write(struct cli_state *cli, int fnum, off_t offset, BOOL bigoffset = False; if (size > cli->bufsize) { - cli->outbuf = realloc(cli->outbuf, size + 1024); - cli->inbuf = realloc(cli->inbuf, size + 1024); + cli->outbuf = SMB_REALLOC(cli->outbuf, size + 1024); + cli->inbuf = SMB_REALLOC(cli->inbuf, size + 1024); if (cli->outbuf == NULL || cli->inbuf == NULL) return False; cli->bufsize = size + 1024; diff --git a/source3/libsmb/clitrans.c b/source3/libsmb/clitrans.c index ae44ca1a779..761741a91bc 100644 --- a/source3/libsmb/clitrans.c +++ b/source3/libsmb/clitrans.c @@ -210,7 +210,7 @@ BOOL cli_receive_trans(struct cli_state *cli,int trans, /* allocate it */ if (total_data!=0) { - tdata = Realloc(*data,total_data); + tdata = SMB_REALLOC(*data,total_data); if (!tdata) { DEBUG(0,("cli_receive_trans: failed to enlarge data buffer\n")); cli_signing_trans_stop(cli); @@ -221,7 +221,7 @@ BOOL cli_receive_trans(struct cli_state *cli,int trans, } if (total_param!=0) { - tparam = Realloc(*param,total_param); + tparam = SMB_REALLOC(*param,total_param); if (!tparam) { DEBUG(0,("cli_receive_trans: failed to enlarge param buffer\n")); cli_signing_trans_stop(cli); @@ -527,7 +527,7 @@ BOOL cli_receive_nt_trans(struct cli_state *cli, /* allocate it */ if (total_data) { - tdata = Realloc(*data,total_data); + tdata = SMB_REALLOC(*data,total_data); if (!tdata) { DEBUG(0,("cli_receive_nt_trans: failed to enlarge data buffer to %d\n",total_data)); cli_signing_trans_stop(cli); @@ -538,7 +538,7 @@ BOOL cli_receive_nt_trans(struct cli_state *cli, } if (total_param) { - tparam = Realloc(*param,total_param); + tparam = SMB_REALLOC(*param,total_param); if (!tparam) { DEBUG(0,("cli_receive_nt_trans: failed to enlarge param buffer to %d\n", total_param)); cli_signing_trans_stop(cli); diff --git a/source3/libsmb/conncache.c b/source3/libsmb/conncache.c index 15cc75b129e..fe863db422a 100644 --- a/source3/libsmb/conncache.c +++ b/source3/libsmb/conncache.c @@ -115,8 +115,7 @@ void add_failed_connection_entry(const char *domain, const char *server, NTSTATU /* Create negative lookup cache entry for this domain and controller */ - if ( !(fcc = (struct failed_connection_cache *)malloc(sizeof(struct failed_connection_cache))) ) - { + if ( !(fcc = SMB_MALLOC_P(struct failed_connection_cache)) ) { DEBUG(0, ("malloc failed in add_failed_connection_entry!\n")); return; } diff --git a/source3/libsmb/libsmb_cache.c b/source3/libsmb/libsmb_cache.c index caf226c5a6a..ddb27535233 100644 --- a/source3/libsmb/libsmb_cache.c +++ b/source3/libsmb/libsmb_cache.c @@ -55,7 +55,7 @@ static int smbc_add_cached_server(SMBCCTX * context, SMBCSRV * new, { struct smbc_server_cache * srvcache = NULL; - if (!(srvcache = malloc(sizeof(*srvcache)))) { + if (!(srvcache = SMB_MALLOC_P(struct smbc_server_cache))) { errno = ENOMEM; DEBUG(3, ("Not enough space for server cache allocation\n")); return 1; @@ -65,25 +65,25 @@ static int smbc_add_cached_server(SMBCCTX * context, SMBCSRV * new, srvcache->server = new; - srvcache->server_name = strdup(server); + srvcache->server_name = SMB_STRDUP(server); if (!srvcache->server_name) { errno = ENOMEM; goto failed; } - srvcache->share_name = strdup(share); + srvcache->share_name = SMB_STRDUP(share); if (!srvcache->share_name) { errno = ENOMEM; goto failed; } - srvcache->workgroup = strdup(workgroup); + srvcache->workgroup = SMB_STRDUP(workgroup); if (!srvcache->workgroup) { errno = ENOMEM; goto failed; } - srvcache->username = strdup(username); + srvcache->username = SMB_STRDUP(username); if (!srvcache->username) { errno = ENOMEM; goto failed; diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index c4be848cc17..83088a14def 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -73,7 +73,7 @@ static int add_fd(SMBCFILE * file) return -1; } - f = malloc(sizeof(struct smbc_compat_fdlist)); + f = SMB_MALLOC_P(struct smbc_compat_fdlist); if (!f) { errno = ENOMEM; return -1; diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index 3dec0c92b48..df9c4ddcadc 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -99,7 +99,7 @@ decode_urlpart(char *segment, size_t sizeof_segment) } /* make a copy of the old one */ - new_usegment = (char*)malloc( old_length * 3 + 1 ); + new_usegment = (char*)SMB_MALLOC( old_length * 3 + 1 ); while( i < old_length ) { int bReencode = False; @@ -671,7 +671,7 @@ SMBCSRV *smbc_server(SMBCCTX *context, * Let's find a free server_fd */ - srv = (SMBCSRV *)malloc(sizeof(*srv)); + srv = SMB_MALLOC_P(SMBCSRV); if (!srv) { errno = ENOMEM; goto failed; @@ -776,7 +776,7 @@ SMBCSRV *smbc_attr_server(SMBCCTX *context, return NULL; } - ipc_srv = (SMBCSRV *)malloc(sizeof(*ipc_srv)); + ipc_srv = SMB_MALLOC_P(SMBCSRV); if (!ipc_srv) { errno = ENOMEM; cli_shutdown(ipc_cli); @@ -871,7 +871,7 @@ static SMBCFILE *smbc_open_ctx(SMBCCTX *context, const char *fname, int flags, m } else { - file = malloc(sizeof(SMBCFILE)); + file = SMB_MALLOC_P(SMBCFILE); if (!file) { @@ -895,7 +895,7 @@ static SMBCFILE *smbc_open_ctx(SMBCCTX *context, const char *fname, int flags, m /* Fill in file struct */ file->cli_fd = fd; - file->fname = strdup(fname); + file->fname = SMB_STRDUP(fname); file->srv = srv; file->offset = 0; file->file = True; @@ -1629,7 +1629,7 @@ static int add_dirent(SMBCFILE *dir, const char *name, const char *comment, uint size = sizeof(struct smbc_dirent) + u_name_len + u_comment_len + 1; - dirent = malloc(size); + dirent = SMB_MALLOC(size); if (!dirent) { @@ -1642,7 +1642,7 @@ static int add_dirent(SMBCFILE *dir, const char *name, const char *comment, uint if (dir->dir_list == NULL) { - dir->dir_list = malloc(sizeof(struct smbc_dir_list)); + dir->dir_list = SMB_MALLOC_P(struct smbc_dir_list); if (!dir->dir_list) { SAFE_FREE(dirent); @@ -1656,7 +1656,7 @@ static int add_dirent(SMBCFILE *dir, const char *name, const char *comment, uint } else { - dir->dir_end->next = malloc(sizeof(struct smbc_dir_list)); + dir->dir_end->next = SMB_MALLOC_P(struct smbc_dir_list); if (!dir->dir_end->next) { @@ -1835,7 +1835,7 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname) pstrcpy(workgroup, context->workgroup); - dir = malloc(sizeof(*dir)); + dir = SMB_MALLOC_P(SMBCFILE); if (!dir) { @@ -1847,7 +1847,7 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname) ZERO_STRUCTP(dir); dir->cli_fd = 0; - dir->fname = strdup(fname); + dir->fname = SMB_STRDUP(fname); dir->srv = NULL; dir->offset = 0; dir->file = False; @@ -3110,7 +3110,7 @@ static BOOL add_ace(SEC_ACL **the_acl, SEC_ACE *ace, TALLOC_CTX *ctx) 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); @@ -3143,7 +3143,7 @@ static SEC_DESC *sec_desc_parse(TALLOC_CTX *ctx, } if (StrnCaseCmp(tok,"OWNER:", 6) == 0) { - owner_sid = (DOM_SID *)calloc(1, sizeof(DOM_SID)); + owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); if (!owner_sid || !convert_string_to_sid(ipc_cli, pol, numeric, @@ -3155,7 +3155,7 @@ static SEC_DESC *sec_desc_parse(TALLOC_CTX *ctx, } if (StrnCaseCmp(tok,"OWNER+:", 7) == 0) { - owner_sid = (DOM_SID *)calloc(1, sizeof(DOM_SID)); + owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); if (!owner_sid || !convert_string_to_sid(ipc_cli, pol, False, @@ -3167,7 +3167,7 @@ static SEC_DESC *sec_desc_parse(TALLOC_CTX *ctx, } if (StrnCaseCmp(tok,"GROUP:", 6) == 0) { - grp_sid = (DOM_SID *)calloc(1, sizeof(DOM_SID)); + grp_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); if (!grp_sid || !convert_string_to_sid(ipc_cli, pol, numeric, @@ -3179,7 +3179,7 @@ static SEC_DESC *sec_desc_parse(TALLOC_CTX *ctx, } if (StrnCaseCmp(tok,"GROUP+:", 7) == 0) { - grp_sid = (DOM_SID *)calloc(1, sizeof(DOM_SID)); + grp_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); if (!grp_sid || !convert_string_to_sid(ipc_cli, pol, False, @@ -4273,7 +4273,7 @@ SMBCCTX * smbc_new_context(void) { SMBCCTX * context; - context = malloc(sizeof(SMBCCTX)); + context = SMB_MALLOC_P(SMBCCTX); if (!context) { errno = ENOMEM; return NULL; @@ -4281,7 +4281,7 @@ SMBCCTX * smbc_new_context(void) ZERO_STRUCTP(context); - context->internal = malloc(sizeof(struct smbc_internal_data)); + context->internal = SMB_MALLOC_P(struct smbc_internal_data); if (!context->internal) { errno = ENOMEM; return NULL; @@ -4488,8 +4488,8 @@ SMBCCTX * smbc_init_context(SMBCCTX * context) */ user = getenv("USER"); /* walk around as "guest" if no username can be found */ - if (!user) context->user = strdup("guest"); - else context->user = strdup(user); + if (!user) context->user = SMB_STRDUP("guest"); + else context->user = SMB_STRDUP(user); } if (!context->netbios_name) { @@ -4498,14 +4498,14 @@ SMBCCTX * smbc_init_context(SMBCCTX * context) * back on constructing our netbios name from our hostname etc */ if (global_myname()) { - context->netbios_name = strdup(global_myname()); + context->netbios_name = SMB_STRDUP(global_myname()); } else { /* * Hmmm, I want to get hostname as well, but I am too lazy for the moment */ pid = sys_getpid(); - context->netbios_name = malloc(17); + context->netbios_name = SMB_MALLOC(17); if (!context->netbios_name) { errno = ENOMEM; return NULL; @@ -4518,11 +4518,11 @@ SMBCCTX * smbc_init_context(SMBCCTX * context) if (!context->workgroup) { if (lp_workgroup()) { - context->workgroup = strdup(lp_workgroup()); + context->workgroup = SMB_STRDUP(lp_workgroup()); } else { /* TODO: Think about a decent default workgroup */ - context->workgroup = strdup("samba"); + context->workgroup = SMB_STRDUP("samba"); } } diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index fef769314af..e6868fb3730 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -55,7 +55,7 @@ static struct node_status *parse_node_status(char *p, int *num_names, struct nod if (*num_names == 0) return NULL; - ret = (struct node_status *)malloc(sizeof(struct node_status)* (*num_names)); + ret = SMB_MALLOC_ARRAY(struct node_status,*num_names); if (!ret) return NULL; @@ -478,8 +478,8 @@ struct in_addr *name_query(int fd,const char *name,int name_type, continue; } - tmp_ip_list = (struct in_addr *)Realloc( ip_list, sizeof( ip_list[0] ) - * ( (*count) + nmb2->answers->rdlength/6 ) ); + tmp_ip_list = SMB_REALLOC_ARRAY( ip_list, struct in_addr, + (*count) + nmb2->answers->rdlength/6 ); if (!tmp_ip_list) { DEBUG(0,("name_query: Realloc failed.\n")); @@ -655,7 +655,7 @@ static BOOL convert_ip2service( struct ip_service **return_iplist, struct in_add return False; /* copy the ip address; port will be PORT_NONE */ - if ( (*return_iplist = (struct ip_service*)malloc(count*sizeof(struct ip_service))) == NULL ) { + if ( (*return_iplist = SMB_MALLOC_ARRAY(struct ip_service, count)) == NULL ) { DEBUG(0,("convert_ip2service: malloc failed for %d enetries!\n", count )); return False; } @@ -868,8 +868,8 @@ static BOOL resolve_lmhosts(const char *name, int name_type, if ((name_type2 != -1) && (name_type != name_type2)) continue; - *return_iplist = (struct ip_service *)realloc((*return_iplist), - sizeof(struct ip_service) * ((*return_count)+1)); + *return_iplist = SMB_REALLOC_ARRAY((*return_iplist), struct ip_service, + (*return_count)+1); if ((*return_iplist) == NULL) { DEBUG(3,("resolve_lmhosts: malloc fail !\n")); @@ -919,7 +919,7 @@ static BOOL resolve_hosts(const char *name, int name_type, if (((hp = sys_gethostbyname(name)) != NULL) && (hp->h_addr != NULL)) { struct in_addr return_ip; putip((char *)&return_ip,(char *)hp->h_addr); - *return_iplist = (struct ip_service *)malloc(sizeof(struct ip_service)); + *return_iplist = SMB_MALLOC_P(struct ip_service); if(*return_iplist == NULL) { DEBUG(3,("resolve_hosts: malloc fail !\n")); return False; @@ -958,7 +958,7 @@ static BOOL resolve_ads(const char *name, int name_type, return False; count = count_chars(list, ' ') + 1; - if ( (*return_iplist = malloc(count * sizeof(struct ip_service))) == NULL ) { + if ( (*return_iplist = SMB_MALLOC_ARRAY(struct ip_service, count)) == NULL ) { DEBUG(0,("resolve_hosts: malloc failed for %d entries\n", count )); return False; } @@ -1029,7 +1029,7 @@ BOOL internal_resolve_name(const char *name, int name_type, if (allzeros || allones || is_address) { - if ( (*return_iplist = (struct ip_service *)malloc(sizeof(struct ip_service))) == NULL ) { + if ( (*return_iplist = SMB_MALLOC_P(struct ip_service)) == NULL ) { DEBUG(0,("internal_resolve_name: malloc fail !\n")); return False; } @@ -1333,8 +1333,7 @@ static BOOL get_dc_list(const char *domain, struct ip_service **ip_list, return False; } - if ( (return_iplist = (struct ip_service *) - malloc(num_addresses * sizeof(struct ip_service))) == NULL ) { + if ( (return_iplist = SMB_MALLOC_ARRAY(struct ip_service, num_addresses)) == NULL ) { DEBUG(3,("get_dc_list: malloc fail !\n")); return False; } diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c index 7f22ce0096a..1c93f7b1e2b 100644 --- a/source3/libsmb/nmblib.c +++ b/source3/libsmb/nmblib.c @@ -354,7 +354,7 @@ static BOOL parse_alloc_res_rec(char *inbuf,int *offset,int length, { int i; - *recs = (struct res_rec *)malloc(sizeof(**recs)*count); + *recs = SMB_MALLOC_ARRAY(struct res_rec, count); if (!*recs) return(False); @@ -557,7 +557,7 @@ static struct packet_struct *copy_nmb_packet(struct packet_struct *packet) struct nmb_packet *copy_nmb; struct packet_struct *pkt_copy; - if(( pkt_copy = (struct packet_struct *)malloc(sizeof(*packet))) == NULL) { + if(( pkt_copy = SMB_MALLOC_P(struct packet_struct)) == NULL) { DEBUG(0,("copy_nmb_packet: malloc fail.\n")); return NULL; } @@ -580,22 +580,19 @@ static struct packet_struct *copy_nmb_packet(struct packet_struct *packet) /* Now copy any resource records. */ if (nmb->answers) { - if((copy_nmb->answers = (struct res_rec *) - malloc(nmb->header.ancount * sizeof(struct res_rec))) == NULL) + if((copy_nmb->answers = SMB_MALLOC_ARRAY(struct res_rec,nmb->header.ancount)) == NULL) goto free_and_exit; memcpy((char *)copy_nmb->answers, (char *)nmb->answers, nmb->header.ancount * sizeof(struct res_rec)); } if (nmb->nsrecs) { - if((copy_nmb->nsrecs = (struct res_rec *) - malloc(nmb->header.nscount * sizeof(struct res_rec))) == NULL) + if((copy_nmb->nsrecs = SMB_MALLOC_ARRAY(struct res_rec, nmb->header.nscount)) == NULL) goto free_and_exit; memcpy((char *)copy_nmb->nsrecs, (char *)nmb->nsrecs, nmb->header.nscount * sizeof(struct res_rec)); } if (nmb->additional) { - if((copy_nmb->additional = (struct res_rec *) - malloc(nmb->header.arcount * sizeof(struct res_rec))) == NULL) + if((copy_nmb->additional = SMB_MALLOC_ARRAY(struct res_rec, nmb->header.arcount)) == NULL) goto free_and_exit; memcpy((char *)copy_nmb->additional, (char *)nmb->additional, nmb->header.arcount * sizeof(struct res_rec)); @@ -622,7 +619,7 @@ static struct packet_struct *copy_dgram_packet(struct packet_struct *packet) { struct packet_struct *pkt_copy; - if(( pkt_copy = (struct packet_struct *)malloc(sizeof(*packet))) == NULL) { + if(( pkt_copy = SMB_MALLOC_P(struct packet_struct)) == NULL) { DEBUG(0,("copy_dgram_packet: malloc fail.\n")); return NULL; } @@ -700,7 +697,7 @@ struct packet_struct *parse_packet(char *buf,int length, struct packet_struct *p; BOOL ok=False; - p = (struct packet_struct *)malloc(sizeof(*p)); + p = SMB_MALLOC_P(struct packet_struct); if (!p) return(NULL); diff --git a/source3/libsmb/ntlmssp.c b/source3/libsmb/ntlmssp.c index 6e41a61bf1b..eb1fce54392 100644 --- a/source3/libsmb/ntlmssp.c +++ b/source3/libsmb/ntlmssp.c @@ -766,7 +766,7 @@ NTSTATUS ntlmssp_server_start(NTLMSSP_STATE **ntlmssp_state) mem_ctx = talloc_init("NTLMSSP context"); - *ntlmssp_state = talloc_zero(mem_ctx, sizeof(**ntlmssp_state)); + *ntlmssp_state = TALLOC_ZERO_P(mem_ctx, NTLMSSP_STATE); if (!*ntlmssp_state) { DEBUG(0,("ntlmssp_server_start: talloc failed!\n")); talloc_destroy(mem_ctx); @@ -1075,7 +1075,7 @@ NTSTATUS ntlmssp_client_start(NTLMSSP_STATE **ntlmssp_state) mem_ctx = talloc_init("NTLMSSP Client context"); - *ntlmssp_state = talloc_zero(mem_ctx, sizeof(**ntlmssp_state)); + *ntlmssp_state = TALLOC_ZERO_P(mem_ctx, NTLMSSP_STATE); if (!*ntlmssp_state) { DEBUG(0,("ntlmssp_client_start: talloc failed!\n")); talloc_destroy(mem_ctx); diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c index ed2283725c8..fdfc92a750a 100644 --- a/source3/libsmb/samlogon_cache.c +++ b/source3/libsmb/samlogon_cache.c @@ -188,7 +188,7 @@ NET_USER_INFO_3* netsamlogon_cache_get( TALLOC_CTX *mem_ctx, const DOM_SID *user if ( data.dptr ) { - if ( (user = (NET_USER_INFO_3*)malloc(sizeof(NET_USER_INFO_3))) == NULL ) + if ( (user = SMB_MALLOC_P(NET_USER_INFO_3)) == NULL ) return NULL; prs_init( &ps, 0, mem_ctx, UNMARSHALL ); diff --git a/source3/libsmb/smb_signing.c b/source3/libsmb/smb_signing.c index b02a13c73e1..df69ff3e41f 100644 --- a/source3/libsmb/smb_signing.c +++ b/source3/libsmb/smb_signing.c @@ -54,7 +54,7 @@ static BOOL store_sequence_for_reply(struct outstanding_packet_lookup **list, } } - t = smb_xmalloc(sizeof(*t)); + t = SMB_XMALLOC_P(struct outstanding_packet_lookup); ZERO_STRUCTP(t); t->mid = mid; @@ -459,7 +459,7 @@ BOOL cli_simple_set_signing(struct cli_state *cli, return False; } - data = smb_xmalloc(sizeof(*data)); + data = SMB_XMALLOC_P(struct smb_basic_signing_context); memset(data, '\0', sizeof(*data)); cli->sign_info.signing_context = data; @@ -509,7 +509,7 @@ void cli_signing_trans_start(struct cli_state *cli, uint16 mid) if (!cli->sign_info.doing_signing || !data) return; - data->trans_info = smb_xmalloc(sizeof(struct trans_info_context)); + data->trans_info = SMB_XMALLOC_P(struct trans_info_context); ZERO_STRUCTP(data->trans_info); /* This ensures the sequence is pulled off the outstanding packet list */ @@ -982,7 +982,7 @@ void srv_signing_trans_start(uint16 mid) if (!data) return; - data->trans_info = smb_xmalloc(sizeof(struct trans_info_context)); + data->trans_info = SMB_XMALLOC_P(struct trans_info_context); ZERO_STRUCTP(data->trans_info); data->trans_info->reply_seq_num = data->send_seq_num-1; @@ -1051,7 +1051,7 @@ void srv_set_signing(const DATA_BLOB user_session_key, const DATA_BLOB response) srv_sign_info.doing_signing = True; - data = smb_xmalloc(sizeof(*data)); + data = SMB_XMALLOC_P(struct smb_basic_signing_context); memset(data, '\0', sizeof(*data)); srv_sign_info.signing_context = data; diff --git a/source3/libsmb/spnego.c b/source3/libsmb/spnego.c index 50caf7b4c0e..a0f5565d4f3 100644 --- a/source3/libsmb/spnego.c +++ b/source3/libsmb/spnego.c @@ -42,12 +42,11 @@ static BOOL read_negTokenInit(ASN1_DATA *asn1, negTokenInit_t *token) asn1_start_tag(asn1, ASN1_CONTEXT(0)); asn1_start_tag(asn1, ASN1_SEQUENCE(0)); - token->mechTypes = malloc(sizeof(*token->mechTypes)); + token->mechTypes = SMB_MALLOC_P(char *); for (i = 0; !asn1->has_error && 0 < asn1_tag_remaining(asn1); i++) { token->mechTypes = - realloc(token->mechTypes, (i + 2) * - sizeof(*token->mechTypes)); + SMB_REALLOC_ARRAY(token->mechTypes, char *, i + 2); asn1_read_OID(asn1, token->mechTypes + i); } token->mechTypes[i] = NULL; |