]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: tools: make parseline report the required space for the trailing 0
authorWilly Tarreau <w@1wt.eu>
Mon, 5 May 2025 15:58:04 +0000 (17:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 5 May 2025 15:58:04 +0000 (17:58 +0200)
commit1f51f1c816b43cbfd6526bb17fe1bf9995fc083a
tree9eb9822a4753228541362d69bdd8fcc0ee9f8b6b
parent09a325a4de4aedd8d7d366769d4dd7c5d9a44f25
BUG/MINOR: tools: make parseline report the required space for the trailing 0

The fix in commit 09a325a4de ("BUG/MINOR: tools: always terminate empty
lines") is insufficient. While it properly addresses the lack of trailing
zero, it doesn't account for it in the returned outlen that is used to
allocate a larger line. This happens at boot if the very first line of
the test file is exactly a sharp with nothing else. In this case it will
return a length 0 and the caller (parse_cfg()) will try to re-allocate an
entry of size zero and will fail, bailing out a lack of memory. This time
it should really be OK.

It doesn't need to be backported, unless the patch above would be.
src/tools.c