]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: log: don't try to emit a log if no logger is set
authorWilly Tarreau <w@1wt.eu>
Thu, 15 Jan 2015 15:29:53 +0000 (16:29 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 15 Jan 2015 15:29:53 +0000 (16:29 +0100)
send_log() calls update_hdr() to build a log header. It may happen
that no logger is defined at all but that we try to send a log anyway
(eg: upon startup). This results in a segfault when building the log
header because logline was never allocated.

This bug was revealed by the recent log-tag changes because the logline
is dereferenced after the call to snprintf(). So in 1.5 on most platforms
it has no impact because snprintf() will ignore NULL, but not necessarily
on all platforms.

The fix needs to be backported to 1.5.

src/log.c

index 4843113287b3ee6abe1591a0b9ec5d16ff6dba4d..6c01248e39cce379f2689c920987a7962444ca83 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -772,7 +772,7 @@ void send_log(struct proxy *p, int level, const char *format, ...)
        char *dataptr;
        int  data_len;
 
-       if (level < 0 || format == NULL)
+       if (level < 0 || format == NULL || logline == NULL)
                return;
 
        dataptr = update_log_hdr(p->log_tag ? p->log_tag : global.log_tag); /* update log header and skip it */