summaryrefslogtreecommitdiffstats
path: root/source/libsmb/namequery.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-12-07 18:25:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:53:32 -0500
commit620f2e608f70ba92f032720c031283d295c5c06a (patch)
treeec3dd5fcf29eaa98a26ddeae3acb7a89fd0e0fb8 /source/libsmb/namequery.c
parent12440744ba36445186042c8c254785766cce5385 (diff)
downloadsamba-620f2e608f70ba92f032720c031283d295c5c06a.tar.gz
samba-620f2e608f70ba92f032720c031283d295c5c06a.tar.xz
samba-620f2e608f70ba92f032720c031283d295c5c06a.zip
r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation
functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy.
Diffstat (limited to 'source/libsmb/namequery.c')
-rw-r--r--source/libsmb/namequery.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c
index fef769314af..e6868fb3730 100644
--- a/source/libsmb/namequery.c
+++ b/source/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;
}