]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: chunk: fix infinite loop in get_larger_trash_chunk()
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 7 Apr 2026 07:48:11 +0000 (09:48 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 7 Apr 2026 12:20:38 +0000 (14:20 +0200)
commit782a1b5888beba64f9532152acebc9a1e56e92ca
tree94ce3227b268f6a6f15886bfdf7ebaf06e80c46d
parentf712841cf09ecc13cd6e26d161cd2f685d84a4cd
BUG/MEDIUM: chunk: fix infinite loop in get_larger_trash_chunk()

When the input chunk is already the large buffer (chk->size ==
large_trash_size), the <= comparison still matched and returned
another large buffer of the same size. Callers that retry on a
non-NULL return value (sample.c:4567 in json_query) loop forever.

The json_query infinite loop is trivially triggered: mjson_unescape()
returns -1 not only when the output buffer is too small but also for
any \uXXYY escape where XX != "00" (mjson.c:305) and for invalid
escapes like \q. The retry loop assumes -1 always means "grow the
buffer", so a 14-byte JSON body of {"k":"\u0100"} hangs the worker
thread permanently. Send N such requests to exhaust all worker
threads.

Use < instead of <= so a chunk that is already large yields NULL.
This also fixes the json converter overflow at sample.c:2869 where
no recheck happens after the "growth" returned a same-size buffer.

Introduced in commit ce912271db4e ("MEDIUM: chunk: Add support for
large chunks"). No backport needed.
src/chunk.c