]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: peers: fix decoding of multi-byte length in stick-table messages
authorWilly Tarreau <w@1wt.eu>
Fri, 13 Nov 2020 13:10:20 +0000 (14:10 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 Nov 2020 14:21:50 +0000 (15:21 +0100)
commit1dfd4f106f15bc4e6e992f8babbc863c12975b5a
tree0d888acf5a1b4731ebdf75421d859c932da8b608
parentea875e62e6b2f69c50533c5cd52eb5284c69723f
BUG/MEDIUM: peers: fix decoding of multi-byte length in stick-table messages

There is a bug in peer_recv_msg() due to an incorrect cast when trying
to decode the varint length of a stick-table message, causing lengths
comprised between 128 and 255 to consume one extra byte, ending in
protocol errors.  The root cause of this is that peer_recv_msg() tries
hard to reimplement all the parsing and control that is already done in
intdecode() just to measure the length before calling it. And it got it
wrong.

Let's just get rid of this unneeded code duplication and solely rely on
intdecode() instead. The bug was introduced in 2.0 as part of a cleanup
pass on this code with commit 95203f218 ("MINOR: peers: Move high level
receive code to reduce the size of I/O handler."), so this patch must
be backported to 2.0.

Thanks to Yves Lafon for reporting the problem.
src/peers.c