]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: tools: always terminate empty lines
authorWilly Tarreau <w@1wt.eu>
Mon, 5 May 2025 15:33:22 +0000 (17:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 5 May 2025 15:33:22 +0000 (17:33 +0200)
Since latest commit 7e4a2f39ef ("BUG/MINOR: tools: do not create an empty
arg from trailing spaces"), an empty line will no longer produce an arg
and no longer append a trailing zero to them. This was not visible because
one is already present in the input string, however all the trailing args
are set to out+outpos-1, which now points one char before the buffer since
nothing was emitted, and was noticed by ASAN, and/or when parsing garbage.
Let's make sure to always emit the zero for empty lines as well to address
this issue. No backport is needed unless the patch above gets backported.

src/tools.c

index 06b8b201813573b1561a5f2c5514ba6dc65586c3..fbb4c4781b06bda19066541d5f9509a7b68c4079 100644 (file)
@@ -6507,6 +6507,10 @@ uint32_t parse_line(char *in, char *out, size_t *outlen, char **args, int *nbarg
        *nbargs = arg;
        *outlen = outpos;
 
+       /* make sure empty lines are terminated */
+       if (!arg)
+               EMIT_CHAR(0);
+
        /* empty all trailing args by making them point to the trailing zero,
         * at least the last one in any case.
         */