]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: log: prevent saddr NULL deref in syslog_io_handler()
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 17 Mar 2025 23:09:59 +0000 (00:09 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Mon, 17 Mar 2025 23:13:19 +0000 (00:13 +0100)
In ad0133cc ("MINOR: log: handle log-forward "option host""), we
de-reference saddr without first checking if saddr is NULL. In practise
saddr shouldn't be null, but it may be the case if memory error happens
for tcp syslog handler so we must assume that it can be NULL at some
point.

To fix the bug, we simply check for NULL before de-referencing it
under syslog_io_handler(), as the function comment suggests.

No backport needed unless ad0133cc is.

src/log.c

index 73da329396ca344b968e42dffd0b2cd8ffed9d56..f8e48ca861e6e810bb48f3d91521e3878fbc559b 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -5739,7 +5739,7 @@ static void syslog_process_message(struct proxy *frontend, struct listener *l,
 
        parse_log_message(buf->area, buf->data, &level, &facility, metadata, &message, &size);
 
-       if (real_family(saddr->ss_family) == AF_UNIX)
+       if (saddr && real_family(saddr->ss_family) == AF_UNIX)
                saddr = NULL; /* no source information for UNIX addresses */
 
        /* handle host options */