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();