]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: tools: support the documented NULL in cbor_encode_bytes_prefix_bin()
authorWilly Tarreau <w@1wt.eu>
Tue, 1 Sep 2026 16:29:58 +0000 (18:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 3 Sep 2026 06:01:50 +0000 (08:01 +0200)
commit821076f6aeb58950ca60fcc0f676f0ce5a63a544
tree4f142963b04208d759a3244d3dafc9206cfeaa10
parentf0cdc4e9f316d30cabfe257631163502303c25bb
BUG/MINOR: tools: support the documented NULL in cbor_encode_bytes_prefix_bin()

Both cbor_encode_bytes_prefix_bin() and cbor_encode_text_bin() document
that "if <bytes> is NULL, then only the <prefix> (with length) will be
emitted", and the hex variants do implement it, their copy loop being
guarded with "while (bytes && it < len)". The bin one does not: it calls
memcpy() unconditionally, so passing NULL dereferences it and crashes,
and it advances <start> by <len> for bytes it never wrote.

No caller passed NULL so far, which is why this remained unnoticed, but
better fix it before it gets used, as it's trivial.

No backport needed.
src/tools.c