summaryrefslogtreecommitdiff
path: root/source3/nmbd/nmbd_browsesync.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-08-30 04:27:26 +0000
committerAndrew Tridgell <tridge@samba.org>1998-08-30 04:27:26 +0000
commit1778debff146423e3543d40c2fe8413a34888a27 (patch)
tree41119cab58d30a359cd0082ddf3a3ab86e93932b /source3/nmbd/nmbd_browsesync.c
parent48514704c2825bcde8bed3b92255ba2abcb955b4 (diff)
downloadsamba-1778debff146423e3543d40c2fe8413a34888a27.tar.gz
samba-1778debff146423e3543d40c2fe8413a34888a27.tar.bz2
samba-1778debff146423e3543d40c2fe8413a34888a27.zip
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)
Diffstat (limited to 'source3/nmbd/nmbd_browsesync.c')
-rw-r--r--source3/nmbd/nmbd_browsesync.c5
1 files changed, 3 insertions, 2 deletions
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);
}
/****************************************************************************