]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #1268: SIGSEGV after log_reopen.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 22 May 2017 07:20:59 +0000 (07:20 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 22 May 2017 07:20:59 +0000 (07:20 +0000)
git-svn-id: file:///svn/unbound/trunk@4177 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
util/log.c

index b678c2aebe09be3acabea26f249f04815056e449..90d30f4eda50fb18d204573903cbdb4b118de0c9 100644 (file)
@@ -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,
index 439541a7ce4af86696ca48addac648f518f9f38f..c14b45834add44bcc5790b5d25cbf8f9a6d42c50 100644 (file)
@@ -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();