Unverified Commit 46efc088 by Felix Abecassis Committed by Christian Brauner

log: fix infinite loop with multiple lxc.log.syslog keys

This caused the linked list of appenders to loop on itself, creating an infinite logging loop in `__lxc_log_append`. Signed-off-by: 's avatarFelix Abecassis <fabecassis@nvidia.com>
parent cd70a8ed
...@@ -533,6 +533,17 @@ extern int lxc_log_syslog(int facility) ...@@ -533,6 +533,17 @@ extern int lxc_log_syslog(int facility)
lxc_log_category_lxc.appender = &log_appender_syslog; lxc_log_category_lxc.appender = &log_appender_syslog;
return 0; return 0;
} }
appender = lxc_log_category_lxc.appender;
/* Check if syslog was already added, to avoid creating a loop */
while (appender) {
if (appender == &log_appender_syslog) {
/* not an error: openlog re-opened the connection */
return 0;
}
appender = appender->next;
}
appender = lxc_log_category_lxc.appender; appender = lxc_log_category_lxc.appender;
while (appender->next != NULL) while (appender->next != NULL)
appender = appender->next; appender = appender->next;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment