summaryrefslogtreecommitdiff
path: root/source3/nmbd
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
commitacf9d61421faa6c0055d57fdee7db300dc5431aa (patch)
tree5482afecfe9b4a68b9a1f18d541a3109f8143ab7 /source3/nmbd
parent3bd3be97dc8a581c0502410453091c195e322766 (diff)
downloadsamba-acf9d61421faa6c0055d57fdee7db300dc5431aa.tar.gz
samba-acf9d61421faa6c0055d57fdee7db300dc5431aa.tar.bz2
samba-acf9d61421faa6c0055d57fdee7db300dc5431aa.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. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a)
Diffstat (limited to 'source3/nmbd')
-rw-r--r--source3/nmbd/nmbd_become_lmb.c4
-rw-r--r--source3/nmbd/nmbd_browserdb.c2
-rw-r--r--source3/nmbd/nmbd_browsesync.c2
-rw-r--r--source3/nmbd/nmbd_incomingrequests.c2
-rw-r--r--source3/nmbd/nmbd_namelistdb.c8
-rw-r--r--source3/nmbd/nmbd_nameregister.c4
-rw-r--r--source3/nmbd/nmbd_packets.c10
-rw-r--r--source3/nmbd/nmbd_processlogon.c3
-rw-r--r--source3/nmbd/nmbd_responserecordsdb.c4
-rw-r--r--source3/nmbd/nmbd_serverlistdb.c2
-rw-r--r--source3/nmbd/nmbd_subnetdb.c4
-rw-r--r--source3/nmbd/nmbd_synclists.c2
-rw-r--r--source3/nmbd/nmbd_winsproxy.c4
-rw-r--r--source3/nmbd/nmbd_winsserver.c6
-rw-r--r--source3/nmbd/nmbd_workgroupdb.c2
15 files changed, 29 insertions, 30 deletions
diff --git a/source3/nmbd/nmbd_become_lmb.c b/source3/nmbd/nmbd_become_lmb.c
index c536deb6f4..b928a8a7c5 100644
--- a/source3/nmbd/nmbd_become_lmb.c
+++ b/source3/nmbd/nmbd_become_lmb.c
@@ -206,7 +206,7 @@ static void release_1d_name( struct subnet_record *subrec, const char *workgroup
struct userdata_struct *userdata;
size_t size = sizeof(struct userdata_struct) + sizeof(BOOL);
- if((userdata = (struct userdata_struct *)malloc(size)) == NULL) {
+ if((userdata = (struct userdata_struct *)SMB_MALLOC(size)) == NULL) {
DEBUG(0,("release_1d_name: malloc fail.\n"));
return;
}
@@ -545,7 +545,7 @@ in workgroup %s on subnet %s\n",
subrec->work_changed = True;
/* Setup the userdata_struct. */
- if((userdata = (struct userdata_struct *)malloc(size)) == NULL) {
+ if((userdata = (struct userdata_struct *)SMB_MALLOC(size)) == NULL) {
DEBUG(0,("become_local_master_browser: malloc fail.\n"));
return;
}
diff --git a/source3/nmbd/nmbd_browserdb.c b/source3/nmbd/nmbd_browserdb.c
index c92513fae8..e8797a99d5 100644
--- a/source3/nmbd/nmbd_browserdb.c
+++ b/source3/nmbd/nmbd_browserdb.c
@@ -87,7 +87,7 @@ struct browse_cache_record *create_browser_in_lmb_cache( const char *work_name,
struct browse_cache_record *browc;
time_t now = time( NULL );
- browc = (struct browse_cache_record *)malloc( sizeof( *browc ) );
+ browc = SMB_MALLOC_P(struct browse_cache_record);
if( NULL == browc ) {
DEBUG( 0, ("create_browser_in_lmb_cache: malloc fail !\n") );
diff --git a/source3/nmbd/nmbd_browsesync.c b/source3/nmbd/nmbd_browsesync.c
index 56ffdc2670..03234bb98f 100644
--- a/source3/nmbd/nmbd_browsesync.c
+++ b/source3/nmbd/nmbd_browsesync.c
@@ -324,7 +324,7 @@ static void find_domain_master_name_query_success(struct subnet_record *subrec,
/* Setup the userdata_struct - this is copied so we can use
a stack variable for this. */
- if((userdata = (struct userdata_struct *)malloc(size)) == NULL) {
+ if((userdata = (struct userdata_struct *)SMB_MALLOC(size)) == NULL) {
DEBUG(0, ("find_domain_master_name_query_success: malloc fail.\n"));
return;
}
diff --git a/source3/nmbd/nmbd_incomingrequests.c b/source3/nmbd/nmbd_incomingrequests.c
index 9214594096..7fac8c2573 100644
--- a/source3/nmbd/nmbd_incomingrequests.c
+++ b/source3/nmbd/nmbd_incomingrequests.c
@@ -516,7 +516,7 @@ void process_name_query_request(struct subnet_record *subrec, struct packet_stru
if (namerec->data.num_ips == 1) {
prdata = rdata;
} else {
- if ((prdata = (char *)malloc( namerec->data.num_ips * 6 )) == NULL) {
+ if ((prdata = (char *)SMB_MALLOC( namerec->data.num_ips * 6 )) == NULL) {
DEBUG(0,("process_name_query_request: malloc fail !\n"));
return;
}
diff --git a/source3/nmbd/nmbd_namelistdb.c b/source3/nmbd/nmbd_namelistdb.c
index bb14ff7641..bdb308a2ea 100644
--- a/source3/nmbd/nmbd_namelistdb.c
+++ b/source3/nmbd/nmbd_namelistdb.c
@@ -181,14 +181,14 @@ struct name_record *add_name_to_subnet( struct subnet_record *subrec,
struct name_record *namerec;
time_t time_now = time(NULL);
- namerec = (struct name_record *)malloc( sizeof(*namerec) );
+ namerec = SMB_MALLOC_P(struct name_record);
if( NULL == namerec ) {
DEBUG( 0, ( "add_name_to_subnet: malloc fail.\n" ) );
return( NULL );
}
memset( (char *)namerec, '\0', sizeof(*namerec) );
- namerec->data.ip = (struct in_addr *)malloc( sizeof(struct in_addr) * num_ips );
+ namerec->data.ip = SMB_MALLOC_ARRAY( struct in_addr, num_ips );
if( NULL == namerec->data.ip ) {
DEBUG( 0, ( "add_name_to_subnet: malloc fail when creating ip_flgs.\n" ) );
ZERO_STRUCTP(namerec);
@@ -329,7 +329,7 @@ void add_ip_to_name_record( struct name_record *namerec, struct in_addr new_ip )
if( find_ip_in_name_record( namerec, new_ip ) )
return;
- new_list = (struct in_addr *)malloc( (namerec->data.num_ips + 1) * sizeof(struct in_addr) );
+ new_list = SMB_MALLOC_ARRAY( struct in_addr, namerec->data.num_ips + 1);
if( NULL == new_list ) {
DEBUG(0,("add_ip_to_name_record: Malloc fail !\n"));
return;
@@ -460,7 +460,7 @@ void add_samba_names_to_subnet( struct subnet_record *subrec )
/* Create an IP list containing all our known subnets. */
num_ips = iface_count();
- iplist = (struct in_addr *)malloc( num_ips * sizeof(struct in_addr) );
+ iplist = SMB_MALLOC_ARRAY( struct in_addr, num_ips);
if( NULL == iplist ) {
DEBUG(0,("add_samba_names_to_subnet: Malloc fail !\n"));
return;
diff --git a/source3/nmbd/nmbd_nameregister.c b/source3/nmbd/nmbd_nameregister.c
index 4e11881f06..8f2a889254 100644
--- a/source3/nmbd/nmbd_nameregister.c
+++ b/source3/nmbd/nmbd_nameregister.c
@@ -306,7 +306,7 @@ static void multihomed_register_one(struct nmb_name *nmbname,
struct in_addr wins_ip = wins_srv_ip_tag(tag, ip);
fstring ip_str;
- userdata = (struct userdata_struct *)malloc(sizeof(*userdata) + strlen(tag) + 1);
+ userdata = (struct userdata_struct *)SMB_MALLOC(sizeof(*userdata) + strlen(tag) + 1);
if (!userdata) {
DEBUG(0,("Failed to allocate userdata structure!\n"));
return;
@@ -423,7 +423,7 @@ static void multihomed_register_name(struct nmb_name *nmbname, uint16 nb_flags,
for(subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec) )
num_ips++;
- if((ip_list = (struct in_addr *)malloc(num_ips * sizeof(struct in_addr)))==NULL) {
+ if((ip_list = SMB_MALLOC_ARRAY(struct in_addr, num_ips))==NULL) {
DEBUG(0,("multihomed_register_name: malloc fail !\n"));
return;
}
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index a81b28ec74..8a111eb957 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -184,7 +184,7 @@ static struct packet_struct *create_and_init_netbios_packet(struct nmb_name *nmb
struct nmb_packet *nmb = NULL;
/* Allocate the packet_struct we will return. */
- if((packet = (struct packet_struct *)malloc(sizeof(*packet))) == NULL) {
+ if((packet = SMB_MALLOC_P(struct packet_struct)) == NULL) {
DEBUG(0,("create_and_init_netbios_packet: malloc fail (1) for packet struct.\n"));
return NULL;
}
@@ -230,7 +230,7 @@ static BOOL create_and_init_additional_record(struct packet_struct *packet,
{
struct nmb_packet *nmb = &packet->packet.nmb;
- if((nmb->additional = (struct res_rec *)malloc(sizeof(struct res_rec))) == NULL) {
+ if((nmb->additional = SMB_MALLOC_P(struct res_rec)) == NULL) {
DEBUG(0,("initiate_name_register_packet: malloc fail for additional record.\n"));
return False;
}
@@ -534,7 +534,7 @@ void queue_wins_refresh(struct nmb_name *nmbname,
DEBUG(6,("Refreshing name %s IP %s with WINS server %s using tag '%s'\n",
nmb_namestr(nmbname), ip_str, inet_ntoa(wins_ip), tag));
- userdata = (struct userdata_struct *)malloc(sizeof(*userdata) + strlen(tag) + 1);
+ userdata = (struct userdata_struct *)SMB_MALLOC(sizeof(*userdata) + strlen(tag) + 1);
if (!userdata) {
DEBUG(0,("Failed to allocate userdata structure!\n"));
return;
@@ -1645,7 +1645,7 @@ static BOOL create_listen_fdset(fd_set **ppset, int **psock_array, int *listen_n
struct subnet_record *subrec = NULL;
int count = 0;
int num = 0;
- fd_set *pset = (fd_set *)malloc(sizeof(fd_set));
+ fd_set *pset = SMB_MALLOC_P(fd_set);
if(pset == NULL) {
DEBUG(0,("create_listen_fdset: malloc fail !\n"));
@@ -1662,7 +1662,7 @@ only use %d.\n", (count*2) + 2, FD_SETSIZE));
return True;
}
- if((sock_array = (int *)malloc(((count*2) + 2)*sizeof(int))) == NULL) {
+ if((sock_array = SMB_MALLOC_ARRAY(int, (count*2) + 2)) == NULL) {
DEBUG(0,("create_listen_fdset: malloc fail for socket array.\n"));
return True;
}
diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c
index ae4011eb8f..5c0fc2c521 100644
--- a/source3/nmbd/nmbd_processlogon.c
+++ b/source3/nmbd/nmbd_processlogon.c
@@ -577,8 +577,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
return;
}
- db_info = (struct sam_database_info *)
- malloc(sizeof(struct sam_database_info) * db_count);
+ db_info = SMB_MALLOC_ARRAY(struct sam_database_info, db_count);
if (db_info == NULL) {
DEBUG(3, ("out of memory allocating info for %d databases\n", db_count));
diff --git a/source3/nmbd/nmbd_responserecordsdb.c b/source3/nmbd/nmbd_responserecordsdb.c
index 30c0c12950..a5903ef462 100644
--- a/source3/nmbd/nmbd_responserecordsdb.c
+++ b/source3/nmbd/nmbd_responserecordsdb.c
@@ -105,7 +105,7 @@ struct response_record *make_response_record( struct subnet_record *subrec,
struct response_record *rrec;
struct nmb_packet *nmb = &p->packet.nmb;
- if (!(rrec = (struct response_record *)malloc(sizeof(*rrec)))) {
+ if (!(rrec = SMB_MALLOC_P(struct response_record))) {
DEBUG(0,("make_response_queue_record: malloc fail for response_record.\n"));
return NULL;
}
@@ -133,7 +133,7 @@ struct response_record *make_response_record( struct subnet_record *subrec,
} else {
/* Primitive userdata, do a memcpy. */
if((rrec->userdata = (struct userdata_struct *)
- malloc(sizeof(struct userdata_struct)+userdata->userdata_len)) == NULL) {
+ SMB_MALLOC(sizeof(struct userdata_struct)+userdata->userdata_len)) == NULL) {
DEBUG(0,("make_response_queue_record: malloc fail for userdata.\n"));
ZERO_STRUCTP(rrec);
SAFE_FREE(rrec);
diff --git a/source3/nmbd/nmbd_serverlistdb.c b/source3/nmbd/nmbd_serverlistdb.c
index e6fad8319d..52d00e1585 100644
--- a/source3/nmbd/nmbd_serverlistdb.c
+++ b/source3/nmbd/nmbd_serverlistdb.c
@@ -137,7 +137,7 @@ workgroup %s. This is a bug.\n", name, work->work_group));
return NULL;
}
- if((servrec = (struct server_record *)malloc(sizeof(*servrec))) == NULL) {
+ if((servrec = SMB_MALLOC_P(struct server_record)) == NULL) {
DEBUG(0,("create_server_entry_on_workgroup: malloc fail !\n"));
return NULL;
}
diff --git a/source3/nmbd/nmbd_subnetdb.c b/source3/nmbd/nmbd_subnetdb.c
index 02a91f2760..ecfd92719b 100644
--- a/source3/nmbd/nmbd_subnetdb.c
+++ b/source3/nmbd/nmbd_subnetdb.c
@@ -147,7 +147,7 @@ static struct subnet_record *make_subnet(const char *name, enum subnet_type type
set_socket_options(dgram_sock,"SO_BROADCAST");
}
- subrec = (struct subnet_record *)malloc(sizeof(*subrec));
+ subrec = SMB_MALLOC_P(struct subnet_record);
if (!subrec) {
DEBUG(0,("make_subnet: malloc fail !\n"));
close(nmb_sock);
@@ -160,7 +160,7 @@ static struct subnet_record *make_subnet(const char *name, enum subnet_type type
namelist_entry_compare,
ubi_trOVERWRITE );
- if((subrec->subnet_name = strdup(name)) == NULL) {
+ if((subrec->subnet_name = SMB_STRDUP(name)) == NULL) {
DEBUG(0,("make_subnet: malloc fail for subnet name !\n"));
close(nmb_sock);
close(dgram_sock);
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index 86f1f760fd..c6bcb3e574 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -143,7 +143,7 @@ done:
return;
}
- s = (struct sync_record *)malloc(sizeof(*s));
+ s = SMB_MALLOC_P(struct sync_record);
if (!s) goto done;
ZERO_STRUCTP(s);
diff --git a/source3/nmbd/nmbd_winsproxy.c b/source3/nmbd/nmbd_winsproxy.c
index cce168adb2..b01ffcffc1 100644
--- a/source3/nmbd/nmbd_winsproxy.c
+++ b/source3/nmbd/nmbd_winsproxy.c
@@ -59,7 +59,7 @@ returned for name %s.\n", nmb_namestr(nmbname) ));
if(num_ips == 1) {
iplist = &ip;
} else {
- if((iplist = (struct in_addr *)malloc( num_ips * sizeof(struct in_addr) )) == NULL) {
+ if((iplist = SMB_MALLOC_ARRAY( struct in_addr, num_ips )) == NULL) {
DEBUG(0,("wins_proxy_name_query_request_success: malloc fail !\n"));
return;
}
@@ -131,7 +131,7 @@ proxy query returns.
static struct userdata_struct *wins_proxy_userdata_copy_fn(struct userdata_struct *userdata)
{
struct packet_struct *p, *copy_of_p;
- struct userdata_struct *new_userdata = (struct userdata_struct *)malloc( userdata->userdata_len );
+ struct userdata_struct *new_userdata = (struct userdata_struct *)SMB_MALLOC( userdata->userdata_len );
if(new_userdata == NULL)
return NULL;
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index 0e0289d9a3..86f5b9c426 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -318,7 +318,7 @@ BOOL initialise_wins(void)
}
/* Allocate the space for the ip_list. */
- if((ip_list = (struct in_addr *)malloc( num_ips * sizeof(struct in_addr))) == NULL) {
+ if((ip_list = SMB_MALLOC_ARRAY( struct in_addr, num_ips)) == NULL) {
DEBUG(0,("initialise_wins: Malloc fail !\n"));
return False;
}
@@ -1379,7 +1379,7 @@ static void process_wins_dmb_query_request(struct subnet_record *subrec,
return;
}
- if((prdata = (char *)malloc( num_ips * 6 )) == NULL) {
+ if((prdata = (char *)SMB_MALLOC( num_ips * 6 )) == NULL) {
DEBUG(0,("process_wins_dmb_query_request: Malloc fail !.\n"));
return;
}
@@ -1442,7 +1442,7 @@ void send_wins_name_query_response(int rcode, struct packet_struct *p,
if( namerec->data.num_ips == 1 ) {
prdata = rdata;
} else {
- if((prdata = (char *)malloc( namerec->data.num_ips * 6 )) == NULL) {
+ if((prdata = (char *)SMB_MALLOC( namerec->data.num_ips * 6 )) == NULL) {
DEBUG(0,("send_wins_name_query_response: malloc fail !\n"));
return;
}
diff --git a/source3/nmbd/nmbd_workgroupdb.c b/source3/nmbd/nmbd_workgroupdb.c
index 8f3ae36b65..917116dd07 100644
--- a/source3/nmbd/nmbd_workgroupdb.c
+++ b/source3/nmbd/nmbd_workgroupdb.c
@@ -71,7 +71,7 @@ static struct work_record *create_workgroup(const char *name, int ttl)
struct subnet_record *subrec;
int t = -1;
- if((work = (struct work_record *)malloc(sizeof(*work))) == NULL) {
+ if((work = SMB_MALLOC_P(struct work_record)) == NULL) {
DEBUG(0,("create_workgroup: malloc fail !\n"));
return NULL;
}