]> git.kaiwu.me - haproxy.git/commit
BUG/MAJOR: buf: make the shift distance check less strict in b_move()
authorWilly Tarreau <w@1wt.eu>
Mon, 16 Nov 2026 15:21:26 +0000 (16:21 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 17 Nov 2026 17:38:15 +0000 (18:38 +0100)
commit91f333d5807e4f92e6dd05de4e2738592d28307f
tree2c94cae29335bb8de1f6f74eb38cb14e4e92210d
parentf16798587eea24aa413a582431f613f5f93c59de
BUG/MAJOR: buf: make the shift distance check less strict in b_move()

Yuqi Qiu and Xiang Li from Nankai University (AOSP Lab) found during
code analysis that the check "BUG_ON(-shift > size)" in b_move() is
incorrect and can trigger too easily. The test as written like this
to only consider a one-byte minimum move, but the function could also
be called either with a larger move and a large offset, or with no data
and a larger move, typically the result of a full buffer deletion. What
matters is that the moved data plus the shift do not go larger than the
buffer.

Let's fix the test to consider both the length and the distance to save
it from triggering too easily.

The test was added in 2.6-dev3 with commit 8873b85bd9 ("DEBUG: buf: add
BUG_ON_HOT() to most buffer management functions") so this fix must be
backported to all stable versions.
src/buf.c