]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: log/tools: fix cbor binary integer encoding regression with x86_64 systems
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 19 Nov 2026 21:32:11 +0000 (22:32 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 19 Nov 2026 21:42:31 +0000 (22:42 +0100)
commitf1ab8bbf6fd5f0ce825ece36cd58c78cb445a506
tree68321fdad226da12ffff66f15a0c203018a57e77
parentaad6aebf748b472f9b52a30ebdf644ac7c79e1d5
BUG/MEDIUM: log/tools: fix cbor binary integer encoding regression with x86_64 systems

A regression was introduced in commit c1abbb11f ("OPTIM: log/tools:
switch from function pointer design to dual mode HEX/BIN design for
CBOR encoding").

Indeed, it was assumed that for x86_64 systems that the byte order
for uint64_t was already correct and that the value could be written
as-is. This is totally wrong, because x86_64 is little endian while
CBOR is big endian. Because of this mistake, values greater than 24
were written in reverse/incorrect order when using
cbor_encode_uint64_prefix_bin().

To fix the issue, instead of completely ditching the fast-path,
let's leverage htons, htonl and my_htonll for 2, 4 and 8 bytes
value respectively (since the value length is known under the
function), as they are less expensive than writing the value 1
byte at a time.

Many thanks to Dragan Dosen and Martin Mirchev for having reported the
issue.

No backport needed.
src/tools.c