]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: tcpcheck: do not run a regex on an unallocated buffer
authorWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 09:58:32 +0000 (11:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 14:11:24 +0000 (16:11 +0200)
commit84e4da5cdf68430c87f2dc42f31c470eefd8bb95
tree15ef949795bef91ea7b5673aeaa0258a852c93a9
parent813c25055d539802d68b503913a6a298f85d491a
BUG/MEDIUM: tcpcheck: do not run a regex on an unallocated buffer

A "tcp-check expect rstring" rule can be evaluated while the input
buffer of the check is not allocated, in which case b_head() returns
NULL, which is not compatible with regex_exec2() that wants a writable
buffer to write a trailing zero, and dies.

By luck, the surrounding cases work by chance because my_memmem()
returns NULL on NULL, and the binary regex works on a trash buffer
(hence always allocated). When using PCRE/PCRE2 it doesn't crash
either because both return an error for a NULL subject, so only a
pure build with libc regex fails.

It's not easy to reproduce, it requires to run many (~2*nproc) parallel
instances of reg-tests/checks/tcp-check_min-recv.vtc several times
(~200) to see it, but it does happend.

The rule now reports no match when no buffer is allocated, which is
what the string and binary cases already do in the same situation

This can be backported to stable versions.
src/tcpcheck.c