summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2016-02-11 21:53:55 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2016-02-11 21:53:55 +0100
commitc2106b674ca632f7c0bffd7cab4b1940f74d353c (patch)
tree708b86d8fd073031d55315782e4a10cfe0f9ba71
parent487c6961cb29046dbe9560262e3e742e38691b83 (diff)
Unix: Fix bug in syslog name handling
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.
-rw-r--r--sysdep/unix/log.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sysdep/unix/log.c b/sysdep/unix/log.c
index 7cb26360..b90bbbd2 100644
--- a/sysdep/unix/log.c
+++ b/sysdep/unix/log.c
@@ -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
}