diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 24 | ||||
-rw-r--r-- | source3/nmbd/nmbd_become_lmb.c | 23 | ||||
-rw-r--r-- | source3/nmbd/nmbd_browsesync.c | 9 | ||||
-rw-r--r-- | source3/nmbd/nmbd_incomingdgrams.c | 4 |
4 files changed, 36 insertions, 24 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index e26c1889a1..a8471d0c2d 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -437,18 +437,18 @@ void mdfour(unsigned char *out, unsigned char *in, int n); /*The following definitions come from mem_man/mem_man.c */ -void *mem_malloc(size_t size,char *file,int line); -char *mem_strdup(char *s, char *file, int line); -int mem_free(void *ptr,char *file,int line); -void mem_write_info(void *ptr,FILE *outfile); -char *mem_query_file(void *ptr); -int mem_query_line(void *ptr); -int mem_test(void *ptr); -void mem_write_status(FILE *outfile); -void mem_write_verbose(FILE *outfile); -void mem_write_errors(FILE *outfile); -void mem_set_multiplier(int multiplier); -void *mem_resize(void *ptr,size_t newsize); +void *smb_mem_malloc(size_t size,char *file,int line); +char *smb_mem_strdup(char *s, char *file, int line); +int smb_mem_free(void *ptr,char *file,int line); +void smb_mem_write_info(void *ptr,FILE *outfile); +char *smb_mem_query_file(void *ptr); +int smb_mem_query_line(void *ptr); +int smb_mem_test(void *ptr); +void smb_mem_write_status(FILE *outfile); +void smb_mem_write_verbose(FILE *outfile); +void smb_mem_write_errors(FILE *outfile); +void smb_mem_set_multiplier(int multiplier); +void *smb_mem_resize(void *ptr,size_t newsize); /*The following definitions come from message.c */ diff --git a/source3/nmbd/nmbd_become_lmb.c b/source3/nmbd/nmbd_become_lmb.c index 2d9f2cce55..7bfd558003 100644 --- a/source3/nmbd/nmbd_become_lmb.c +++ b/source3/nmbd/nmbd_become_lmb.c @@ -248,7 +248,6 @@ void unbecome_local_master_browser(struct subnet_record *subrec, struct work_rec struct name_record *namerec; struct nmb_name nmbname; struct userdata_struct *userdata; - char ud[sizeof(struct userdata_struct) + sizeof(fstring)+1]; /* Sanity check. */ @@ -268,9 +267,11 @@ in workgroup %s on subnet %s\n", work->mst_state = MST_UNBECOMING_MASTER; /* Setup the userdata for the MSBROWSE name release. */ - /* Setup the userdata_struct - this is copied so we can use - a stack variable for this. */ - userdata = (struct userdata_struct *)ud; + if((userdata = (struct userdata_struct *)malloc( sizeof(struct userdata_struct) + sizeof(fstring)+1)) == NULL) + { + DEBUG(0,("unbecome_local_master_browser: malloc fail.\n")); + return; + } userdata->copy_fn = NULL; userdata->free_fn = NULL; @@ -286,6 +287,8 @@ in workgroup %s on subnet %s\n", release_msbrowse_name_fail, userdata); } + + free((char *)userdata); } /**************************************************************************** @@ -481,7 +484,6 @@ void become_local_master_browser(struct subnet_record *subrec, struct work_recor { struct server_record *servrec; struct userdata_struct *userdata; - char ud[sizeof(struct userdata_struct) + sizeof(fstring)+1]; /* Sanity check. */ if (!lp_local_master()) @@ -516,9 +518,12 @@ in workgroup %s on subnet %s\n", /* Tell the namelist writer to write out a change. */ subrec->work_changed = True; - /* Setup the userdata_struct - this is copied so we can use - a stack variable for this. */ - userdata = (struct userdata_struct *)ud; + /* Setup the userdata_struct. */ + if((userdata = (struct userdata_struct *)malloc(sizeof(struct userdata_struct) + sizeof(fstring)+1)) == NULL) + { + DEBUG(0,("become_local_master_browser: malloc fail.\n")); + return; + } userdata->copy_fn = NULL; userdata->free_fn = NULL; @@ -530,6 +535,8 @@ in workgroup %s on subnet %s\n", become_local_master_stage1, become_local_master_fail1, userdata); + + free((char *)userdata); } /*************************************************************** diff --git a/source3/nmbd/nmbd_browsesync.c b/source3/nmbd/nmbd_browsesync.c index cc81807de4..e4231e6017 100644 --- a/source3/nmbd/nmbd_browsesync.c +++ b/source3/nmbd/nmbd_browsesync.c @@ -379,7 +379,6 @@ static void find_domain_master_name_query_success(struct subnet_record *subrec, struct work_record *work; struct nmb_name nmbname; struct userdata_struct *userdata; - char ud[sizeof(struct userdata_struct) + sizeof(fstring)+1]; if (!(work = find_workgroup_on_subnet(subrec, q_name->name))) { DEBUG(0, ("find_domain_master_name_query_success: failed to find \ @@ -412,7 +411,11 @@ workgroup %s\n", q_name->name )); /* Setup the userdata_struct - this is copied so we can use a stack variable for this. */ - userdata = (struct userdata_struct *)ud; + if((userdata = (struct userdata_struct *)malloc(sizeof(struct userdata_struct) + sizeof(fstring)+1)) == NULL) + { + DEBUG(0, ("find_domain_master_name_query_success: malloc fail.\n")); + return; + } userdata->copy_fn = NULL; userdata->free_fn = NULL; @@ -423,6 +426,8 @@ workgroup %s\n", q_name->name )); domain_master_node_status_success, domain_master_node_status_fail, userdata); + + free((char *)userdata); } /**************************************************************************** diff --git a/source3/nmbd/nmbd_incomingdgrams.c b/source3/nmbd/nmbd_incomingdgrams.c index 2396c847a3..b1de27f181 100644 --- a/source3/nmbd/nmbd_incomingdgrams.c +++ b/source3/nmbd/nmbd_incomingdgrams.c @@ -547,7 +547,7 @@ static void send_backup_list_response(struct subnet_record *subrec, { char outbuf[1024]; char *p, *countptr, *nameptr; - int count = 0; + unsigned int count = 0; int len; struct server_record *servrec; @@ -582,7 +582,7 @@ static void send_backup_list_response(struct subnet_record *subrec, if((sizeof(outbuf) - len) < 16) break; - if(count >= max_number_requested) + if(count >= (unsigned int)max_number_requested) break; if(strnequal(servrec->serv.name, myname,15)) |