]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: mux_h1: fix stack buffer overflow in h1_append_chunk_size()
authorWilly Tarreau <w@1wt.eu>
Sun, 26 Apr 2026 11:51:16 +0000 (13:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 27 Apr 2026 16:58:51 +0000 (18:58 +0200)
commit1ef74fc7cec12eba7daeef0b44f96b1ad4f5e127
tree245e53950a37a38ea44af3e1dfd785267474da38
parent5160b84c7a7ad91151ed7859e25698f96aedb4e4
BUG/MEDIUM: mux_h1: fix stack buffer overflow in h1_append_chunk_size()

The char tmp[10] buffer can only hold 8 hex digits + CRLF suffix. If chksz
exceeds 4GB (0xFFFFFFFF), the do-while loop writes more than 8 hex digits,
overflowing the stack buffer by 1+ bytes. In practice the buffer is aligned
from the end and leaves a 6-byte hole before it on 64-bit systems, leaving
enough room to be harmless, and 4 on 32-bit platforms which save it from
touching lower variables. So it is safe but just by luck.

Fix by increasing tmp[] to 18 bytes, sufficient for up to 16 hex digits
(2^64 - 1) plus CRLF.
src/mux_h1.c