From b067a5e4e83556d11a68ea1837ce4698762c123d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 3 Nov 2009 10:59:18 +0100 Subject: s3: Remove debug_ctx() smbd just crashed on me: In a debug message I called a routine preparing a string that itself used debug_ctx. The outer routine also used it after the inner routine had returned. It was still referencing the talloc context that the outer debug_ctx() had given us, which the inner DEBUG had already freed. --- source3/lib/debug.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'source3/lib/debug.c') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 2e19f89863..e851fd20e9 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -90,8 +90,6 @@ bool AllowDebugChange = True; */ bool override_logfile; -static TALLOC_CTX *tmp_debug_ctx; - /* * This is to allow assignment to DEBUGLEVEL before the debug * system has been initialized. @@ -888,8 +886,6 @@ void check_log_size( void ) } done: - TALLOC_FREE(tmp_debug_ctx); - errno = old_errno; return( 0 ); @@ -1057,12 +1053,12 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func) /* Print it all out at once to prevent split syslog output. */ if( lp_debug_prefix_timestamp() ) { (void)Debug1( "[%s, %2d%s] ", - current_timestring(debug_ctx(), + current_timestring(talloc_tos(), lp_debug_hires_timestamp()), level, header_str); } else { (void)Debug1( "[%s, %2d%s] %s(%s)\n", - current_timestring(debug_ctx(), + current_timestring(talloc_tos(), lp_debug_hires_timestamp()), level, header_str, location, func ); } @@ -1110,14 +1106,3 @@ bool dbghdr(int level, const char *location, const char *func) SAFE_FREE(msgbuf); return ret; } - -/* - * Get us a temporary talloc context usable just for DEBUG arguments - */ -TALLOC_CTX *debug_ctx(void) -{ - if (tmp_debug_ctx == NULL) { - tmp_debug_ctx = talloc_named_const(NULL, 0, "debug_ctx"); - } - return tmp_debug_ctx; -} -- cgit