From: Felix Abecassis Date: Wed, 29 Nov 2017 04:27:39 +0000 (-0800) Subject: log: fix infinite loop with multiple lxc.log.syslog keys X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=46efc0880c27a18465b986fd74d34115da69ad32;p=thirdparty%2Flxc.git 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: Felix Abecassis --- diff --git a/src/lxc/log.c b/src/lxc/log.c index 351b191fb..b62aeb8d2 100644 --- a/src/lxc/log.c +++ b/src/lxc/log.c @@ -533,6 +533,17 @@ extern int lxc_log_syslog(int facility) lxc_log_category_lxc.appender = &log_appender_syslog; 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; while (appender->next != NULL) appender = appender->next;