]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Unix: Fix bug in syslog name handling
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Thu, 11 Feb 2016 20:53:55 +0000 (21:53 +0100)
committerPavel Tvrdik <pawel.tvrdik@gmail.com>
Tue, 3 May 2016 07:25:37 +0000 (09:25 +0200)
Pointer to current_log_name has to be changed even if the name is the
same, because the old one will be invalid/freed after reconfiguration.

sysdep/unix/log.c

index e049473228c5492467ee1156d88068ec270860bc..3a5abc6b48800367fe10a802e6955e2dcccc6d4d 100644 (file)
@@ -284,17 +284,18 @@ log_switch(int debug, list *l, char *new_syslog_name)
   current_log_list = l;
 
 #ifdef HAVE_SYSLOG
-  if (current_syslog_name && new_syslog_name &&
-      !strcmp(current_syslog_name, new_syslog_name))
+  char *old_syslog_name = current_syslog_name;
+  current_syslog_name = new_syslog_name;
+
+  if (old_syslog_name && new_syslog_name &&
+      !strcmp(old_syslog_name, new_syslog_name))
     return;
 
-  if (current_syslog_name)
+  if (old_syslog_name)
     closelog();
 
   if (new_syslog_name)
     openlog(new_syslog_name, LOG_CONS | LOG_NDELAY, LOG_DAEMON);
-
-  current_syslog_name = new_syslog_name;
 #endif
 }