]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: log-forward: make sure the month is unsigned
authorWilly Tarreau <w@1wt.eu>
Sat, 23 May 2026 18:17:16 +0000 (20:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 May 2026 08:16:06 +0000 (10:16 +0200)
In 2.3, in preparation for log forwarding, commit 546488559 ("MEDIUM:
log/sink: re-work and merge of build message API.") extended the log
send API to be able to use metadata from an existing header. However
the month number is parsed from the passed meta-data and compared
against 11 but there's no check for negative values which could in
theory cause a negative monthname[] index.

It can be a problem when the date is received as RFC5424 and forced
to RFC3164 because certain characters in the month field could result
in a negative month value. Let's fix it by turning the month to unsigned
to make sure we only accept months 0..11.

This should be backported to all branches.

src/log.c

index 89318b82c3fb0b0e7f82a713002ae0e579b43a15..c8f85695b1e1dc6769d254a921e1be8ee2037548 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -3319,7 +3319,7 @@ struct ist *build_log_header(struct log_header hdr, size_t *nbelem)
                                break;
                        }
                        else if (metadata && metadata[LOG_META_TIME].len >= LOG_ISOTIME_MINLEN) {
-                               int month;
+                               uint month;
                                char *timestamp = metadata[LOG_META_TIME].ptr;
 
                                /* iso time always begins like this: '1970-01-01T00:00:00' */