BUG/MAJOR: buf: Fix copy of wrapping output data when a buffer is realigned
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 Jan 2023 08:34:47 +0000 (09:34 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 Jan 2023 08:34:49 +0000 (09:34 +0100)
commit61aded057dafc419f62b9534d03e6c99a3405f7a
tree62e0dd6869cee3585dc95bcdbda415d103d64e09
parent31850b470a9c59d04349174df6b51de1efe41420
BUG/MAJOR: buf: Fix copy of wrapping output data when a buffer is realigned

There is a bug in b_slow_realign() function when wrapping output data are
copied in the swap buffer. block1 and block2 sizes are inverted. Thus blocks
with a wrong size are copied. It leads to data mixin if the first block is
in reality larger than the second one or to a copy of data outside the
buffer is the first block is smaller than the second one.

The bug was introduced when the buffer API was refactored in 1.9. It was
found by a code review and seems never to have been triggered in almost 5
years. However, we cannot exclude it is responsible of some unresolved bugs.

This patch should fix issue #1978. It must be backported as far as 2.0.
include/haproxy/buf.h