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.
This commit is contained in:
Ondrej Zajicek (work) 2016-02-11 21:53:55 +01:00
parent 487c6961cb
commit c2106b674c

View file

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