From 1778debff146423e3543d40c2fe8413a34888a27 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 30 Aug 1998 04:27:26 +0000 Subject: added some defensive programming to nmbd. This mostly means zeroing areas of memory before freeing them. While doing this I also found a couple of real bugs. In two places we were freeing some memory that came from the stack, which leads to a certain core dump on many sytems. (This used to be commit c5e5c25c854e54f59291057ba47c4701b5910ebe) --- source3/nmbd/nmbd_browsesync.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/nmbd/nmbd_browsesync.c') diff --git a/source3/nmbd/nmbd_browsesync.c b/source3/nmbd/nmbd_browsesync.c index dcf2ea3c48..bc0cf43f7c 100644 --- a/source3/nmbd/nmbd_browsesync.c +++ b/source3/nmbd/nmbd_browsesync.c @@ -386,6 +386,7 @@ static void find_domain_master_name_query_success(struct subnet_record *subrec, struct work_record *work; struct nmb_name nmbname; struct userdata_struct *userdata; + int size = 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 \ @@ -418,7 +419,7 @@ workgroup %s\n", q_name->name )); /* Setup the userdata_struct - this is copied so we can use a stack variable for this. */ - if((userdata = (struct userdata_struct *)malloc(sizeof(struct userdata_struct) + sizeof(fstring)+1)) == NULL) + if((userdata = (struct userdata_struct *)malloc(size)) == NULL) { DEBUG(0, ("find_domain_master_name_query_success: malloc fail.\n")); return; @@ -434,7 +435,7 @@ workgroup %s\n", q_name->name )); domain_master_node_status_fail, userdata); - free((char *)userdata); + zero_free(userdata, size); } /**************************************************************************** -- cgit