]> git.kaiwu.me - haproxy.git/commit
CLEANUP: tools: make inetaddr_host_lim*() usable on untrusted inputs
authorWilly Tarreau <w@1wt.eu>
Tue, 3 Nov 2026 07:49:52 +0000 (08:49 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 3 Nov 2026 07:57:32 +0000 (08:57 +0100)
commit1e11132396b17ca404e94155d1fcb90cbabd4c37
treefa02ca5d4b7f75594633295732b24c910ea1e56d
parenta0b37fb470a62f5765d53566ebacb64c206564b7
CLEANUP: tools: make inetaddr_host_lim*() usable on untrusted inputs

inetaddr_host_lim() and inetaddr_host_lim_ret() were introduced in 1.4.4
by commit d54bbdce87 ("[MINOR] add very fast IP parsing functions") as
fast parsers for some specific use cases. They expect a delimiter after
the IP address (cr/lf/nul/whatever, in fact, anything not a digit), and
this is how they're currently used. As noted by Md. Raisul Islam Mobin,
they could also be misused by external code not aware of this limitation
which by then saved a few CPU cycles per address at an era where they
were still precious, so let's test the end pointer before reading the
digit to make it more future-proof. If this speed still matters, these
ones could probably be rewritten to benefit from automatic vectorization
on SIMD-capable machines.
src/tools.c