mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-23 10:11:53 +00:00
Fix of shutdown: premature log cleanup led to use-after-free
This commit is contained in:
parent
bb63e99d78
commit
55ee9961e0
@ -387,6 +387,21 @@ default_log_list(int initial, const char **syslog_name)
|
||||
return &log_list;
|
||||
}
|
||||
|
||||
void
|
||||
log_cleanup(int syslog)
|
||||
{
|
||||
struct log_config *l;
|
||||
|
||||
if (current_log_list)
|
||||
WALK_LIST(l, *current_log_list)
|
||||
if (l->rf)
|
||||
log_close(l);
|
||||
|
||||
if (syslog && current_syslog_name)
|
||||
closelog();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
log_switch(int initial, list *logs, const char *new_syslog_name)
|
||||
{
|
||||
@ -399,10 +414,7 @@ log_switch(int initial, list *logs, const char *new_syslog_name)
|
||||
logs = default_log_list(initial, &new_syslog_name);
|
||||
|
||||
/* Close the logs to avoid pinning them on disk when deleted */
|
||||
if (current_log_list)
|
||||
WALK_LIST(l, *current_log_list)
|
||||
if (l->rf)
|
||||
log_close(l);
|
||||
log_cleanup(0);
|
||||
|
||||
/* Reopen the logs, needed for 'configure undo' */
|
||||
if (logs)
|
||||
|
@ -202,7 +202,9 @@ sysdep_preconfig(struct config *c)
|
||||
int
|
||||
sysdep_commit(struct config *new, struct config *old UNUSED)
|
||||
{
|
||||
log_switch(0, &new->logfiles, new->syslog_name);
|
||||
if (!new->shutdown)
|
||||
log_switch(0, &new->logfiles, new->syslog_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -613,6 +615,7 @@ sysdep_shutdown_done(void)
|
||||
unlink_pid_file();
|
||||
unlink(path_control_socket);
|
||||
log_msg(L_FATAL "Shutdown completed");
|
||||
log_cleanup(1);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -122,6 +122,7 @@ void krt_io_init(void);
|
||||
void main_thread_init(void);
|
||||
void log_init_debug(char *); /* Initialize debug dump to given file (NULL=stderr, ""=off) */
|
||||
void log_switch(int initial, list *l, const char *);
|
||||
void log_cleanup(int syslog);
|
||||
|
||||
struct log_config {
|
||||
node n;
|
||||
|
Loading…
Reference in New Issue
Block a user