]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
log: fix infinite loop with multiple lxc.log.syslog keys
authorFelix Abecassis <fabecassis@nvidia.com>
Wed, 29 Nov 2017 04:27:39 +0000 (20:27 -0800)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Dec 2017 11:42:30 +0000 (12:42 +0100)
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 <fabecassis@nvidia.com>
src/lxc/log.c

index 351b191fb93d938d92e712db9a75d8b474009ef5..b62aeb8d222615ab55739229c1cd2781130e32c1 100644 (file)
@@ -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;