]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: tools: improve parse_line()'s robustness against empty args
authorWilly Tarreau <w@1wt.eu>
Mon, 12 May 2025 14:01:27 +0000 (16:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 12 May 2025 14:11:15 +0000 (16:11 +0200)
commit2b60e54fb1fb825a65f0668d83d912d7af873295
treea5b65b4b3e6f969aef89f92a88433a5e241b4465
parent7d057e56af86cdc98c5388986931c247dbafa5b3
BUG/MINOR: tools: improve parse_line()'s robustness against empty args

The fix in 10e6d0bd57 ("BUG/MINOR: tools: only fill first empty arg when
not out of range") was not that good. It focused on protecting against
<arg> becoming out of range to detect we haven't emitted anything, but
it's not the right way to detect this. We're always maintaining arg_start
as a copy of outpos, and that later one is incremented when emitting a
char, so instead of testing args[arg] against out+arg_start, we should
instead check outpos against arg_start, thereby eliminating the <out>
offset and the need to access args[]. This way we now always know if
we've emitted an empty arg without dereferencing args[].

There's no need to backport this unless the fix above is also backported.
src/tools.c