From f9088a5d7500ebb39deff7c839817977c1b1d11c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sat, 23 May 2026 20:17:16 +0200 Subject: [PATCH] BUG/MEDIUM: log-forward: make sure the month is unsigned 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/log.c b/src/log.c index 89318b82c..c8f85695b 100644 --- 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' */