From 1a44a8402efb656680d0ad7d108ce6b44523c60f Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Mon, 22 May 2017 07:20:59 +0000 Subject: [PATCH] - Fix #1268: SIGSEGV after log_reopen. git-svn-id: file:///svn/unbound/trunk@4177 be551aaa-1e26-0410-a405-d3ace91eadb9 --- doc/Changelog | 3 +++ util/log.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index b678c2aeb..90d30f4ed 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +22 May 2017: Wouter + - Fix #1268: SIGSEGV after log_reopen. + 18 May 2017: Wouter - Fix #1265 to use /bin/kill. - Fix #1267: Libunbound validator/val_secalgo.c uses obsolete APIs, diff --git a/util/log.c b/util/log.c index 439541a7c..c14b45834 100644 --- a/util/log.c +++ b/util/log.c @@ -103,8 +103,12 @@ log_init(const char* filename, int use_syslog, const char* chrootdir) use_syslog?"syslog":(filename&&filename[0]?filename:"stderr")); lock_quick_lock(&log_lock); } - if(logfile && logfile != stderr) - fclose(logfile); + if(logfile && logfile != stderr) { + FILE* cl = logfile; + logfile = NULL; /* set to NULL before it is closed, so that + other threads have a valid logfile or NULL */ + fclose(cl); + } #ifdef HAVE_SYSLOG_H if(logging_to_syslog) { closelog();