]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald-native: fix field-count limit off-by-one
authornoxiouz <atiurin@proton.me>
Mon, 6 Apr 2026 10:22:58 +0000 (11:22 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 7 Apr 2026 09:22:45 +0000 (11:22 +0200)
Reject entries once the configured maximum field count is reached.

The previous check used n > ENTRY_FIELD_COUNT_MAX before appending a new field,
which let one extra field through in boundary cases. Switch the check to
n >= ENTRY_FIELD_COUNT_MAX so an entry at the limit is rejected before adding
another property.

Co-developed-by: Codex (GPT-5) <noreply@openai.com>
src/journal/journald-native.c

index 1e2a872c6ed597dea1331b9c47a5878d678dc29c..fade424ebcdefb22767d622775596d5aa27b921b 100644 (file)
@@ -146,7 +146,7 @@ static int manager_process_entry(
                 }
 
                 /* A property follows */
-                if (n > ENTRY_FIELD_COUNT_MAX) {
+                if (n >= ENTRY_FIELD_COUNT_MAX) {
                         log_debug("Received an entry that has more than " STRINGIFY(ENTRY_FIELD_COUNT_MAX) " fields, ignoring entry.");
                         goto finish;
                 }