From 49fe698fe9a794938725efd32b14c6bce95e1ef7 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Sun, 2 Nov 2014 20:21:45 +0100 Subject: [PATCH] nmbd_namelistdb: don't leak lock_path onto talloc tos Also check for allocation failures. Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison --- source3/nmbd/nmbd_namelistdb.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/source3/nmbd/nmbd_namelistdb.c b/source3/nmbd/nmbd_namelistdb.c index c06bddafbdd..313e4a68772 100644 --- a/source3/nmbd/nmbd_namelistdb.c +++ b/source3/nmbd/nmbd_namelistdb.c @@ -642,17 +642,24 @@ static void dump_subnet_namelist( struct subnet_record *subrec, XFILE *fp) void dump_all_namelists(void) { - XFILE *fp; + XFILE *fp; struct subnet_record *subrec; + char *dump_path; - fp = x_fopen(lock_path("namelist.debug"),O_WRONLY|O_CREAT|O_TRUNC, 0644); - - if (!fp) { + dump_path = lock_path("namelist.debug"); + if (dump_path == NULL) { + DEBUG(0, ("out of memory!\n")); + return; + } + + fp = x_fopen(dump_path, (O_WRONLY | O_CREAT | O_TRUNC), 0644); + TALLOC_FREE(dump_path); + if (!fp) { DEBUG(0,("dump_all_namelists: Can't open file %s. Error was %s\n", "namelist.debug",strerror(errno))); return; } - + for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec)) { dump_subnet_namelist( subrec, fp ); } -- 2.11.4.GIT