]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: sample: Fix a possible underflow on be2hex for large chunk size
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 7 Jul 2026 12:13:49 +0000 (14:13 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 8 Jul 2026 06:52:06 +0000 (08:52 +0200)
commitee5cfaf2667bec5930f2ca7aea60ededa1b94ed2
tree3377ce823b39a8f41757a8b2f024b13e598776d6
parente5284428479ac4606a1c9b690990700275848cad
BUG/MINOR: sample: Fix a possible underflow on be2hex for large chunk size

For a chunk size exactly equal to bufsize/2, the "max_size" variable could
underflow if a separator is provided. Indeed, "max_size" is first set to
(trash->size - 2 * chunk_size), so to 0. And on the first iteration, the
separator length is removed, making it to underflow.

On 3.3 and lower it is especially an issue with samples larger than
bufsize/2 because data could be written ouside of the buffer. On 3.4 and
3.5, it is not an issue because we fail to retrieve a chunk.

This should be backported to all supported versions.
src/sample.c