]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: log: always reserve room for trailing 0 when using CBOR encoding helpers
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 6 Aug 2026 19:15:36 +0000 (21:15 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Aug 2026 08:32:55 +0000 (10:32 +0200)
commit378386e14225f6aea45b9254ba00973cdaf20ff8
treec0e6be83b3da1de41f1d2000d0d5622cfaad4cbd
parentd156f6bac2f48482fd76119ff959a1d59fc9038b
BUG/MEDIUM: log: always reserve room for trailing 0 when using CBOR encoding helpers

Logging helpers leveraged by sess_build_logline_orig() can be split in
two different groups. Although they all look similar in their construction
as they take pretty much the same parameters and return the address where
following bytes can be appended, some will always try to append the
terminating NULL byte and return the address of the terminating NULL
byte, while others (which are not specifically text oriented) will simply
use all available space (they don't reserve space for the terminating NULL
byte) and return the address of the byte following the last byte written.
But since they don't try to write the \0 themselves, they will in practise
output one extra byte compared to other helpers. If no precaution is taken
and they are used as drop-in replacement to text oriented ones, this can
cause invalid writes later in the code because sess_build_logline_orig()
will always append the terminating NULL byte (even if it is already set),
thus it is mandatory that the output pointer never reaches the stopmark.

Fortunately, most pitfalls were already avoided in log generation path,
but recent commit c614fd3b ("MINOR: log: add +cbor encoding option")
made use of several encoding helpers which were not text oriented as
text oriented ones. Let's fix that by always securing 1 byte for the
terminating NULL byte when calling them (even if it not used by the
endpoint X format, sess_build_logline_orig() will append it not matter
what, so we have to live with that).

Reported-by: Claude (ANT-2026-QQ17FDX1)
It should be backported up to 3.0.
src/log.c