From 12b9f29b71f2ef523e2668a151f78c105066cf6a Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Thu, 31 May 2012 15:43:14 -0700 Subject: [PATCH] Fix bug #8970 - Possible memory leaks in the samba master process. Signed-off-by: Jeremy Allison --- source3/lib/debug.c | 13 ++++++++----- source3/nmbd/nmbd.c | 3 ++- source3/param/loadparm.c | 6 +++++- source3/smbd/server.c | 1 + source3/winbindd/winbindd.c | 3 ++- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 80b8310..05e9eee 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -657,9 +657,11 @@ bool reopen_logs( void ) SAFE_FREE(fname); fname = SMB_STRDUP(logfname); if (!fname) { + TALLOC_FREE(logfname); return false; } } + TALLOC_FREE(logfname); } debugf = fname; @@ -1028,6 +1030,8 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func) */ if( lp_timestamp_logs() || lp_debug_prefix_timestamp() || !(lp_loaded()) ) { char header_str[200]; + char *curtime = current_timestring(talloc_tos(), + lp_debug_hires_timestamp()); header_str[0] = '\0'; @@ -1050,19 +1054,18 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func) ", class=%s", default_classname_table[cls]); } - + /* Print it all out at once to prevent split syslog output. */ if( lp_debug_prefix_timestamp() ) { (void)Debug1( "[%s, %2d%s] ", - current_timestring(talloc_tos(), - lp_debug_hires_timestamp()), + curtime, level, header_str); } else { (void)Debug1( "[%s, %2d%s] %s(%s)\n", - current_timestring(talloc_tos(), - lp_debug_hires_timestamp()), + curtime, level, header_str, location, func ); } + TALLOC_FREE(curtime); } errno = old_errno; diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 48e6d93..2a7b28d 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -366,11 +366,12 @@ static bool reload_nmbd_services(bool test) set_remote_machine_name("nmbd", False); if ( lp_loaded() ) { - const char *fname = lp_configfile(); + char *fname = lp_configfile(); if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); test = False; } + TALLOC_FREE(fname); } if ( test && !lp_file_list_changed() ) diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 28ffc08..5800bec 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -9283,7 +9283,11 @@ bool lp_load_ex(const char *pszFname, } } - lp_add_auto_services(lp_auto_services()); + { + char *serv = lp_auto_services(); + lp_add_auto_services(serv); + TALLOC_FREE(serv); + } if (add_ipc) { /* When 'restrict anonymous = 2' guest connections to ipc$ diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 201e301..63a9869 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -804,6 +804,7 @@ bool reload_services(bool test) set_dyn_CONFIGFILE(fname); test = False; } + TALLOC_FREE(fname); } reopen_logs(); diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 034e43b..0550da8 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -67,11 +67,12 @@ static bool reload_services_file(const char *lfile) bool ret; if (lp_loaded()) { - const char *fname = lp_configfile(); + char *fname = lp_configfile(); if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); } + TALLOC_FREE(fname); } /* if this is a child, restore the logfile to the special -- 1.7.7.3