]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: vars: only print first invalid char in fill_desc()
authorWilly Tarreau <w@1wt.eu>
Thu, 30 Apr 2026 07:19:53 +0000 (09:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 30 Apr 2026 07:19:53 +0000 (09:19 +0200)
The variable name is passed as (ptr,len) suggesting that certain callers
might not always have 0-terminated strings (e.g. when used in arguments
where closing parenthesis or commas might follow), the error message
carefully tries to designate the first invalid character, yet by mistake
it prints the whole string. This mistake has been there since commit
4834bc773c ("MEDIUM: vars: adds support of variables") in 1.6. Let's
properly report the char as promised instead. This could be backported
but is totally unimportant.

src/vars.c

index 453c5f2edd9a8c87e6d81daafa7e4bb4acdf4cbd..6375e9b34fbb13cd22795f2e6fa50c00496e5ce4 100644 (file)
@@ -328,7 +328,7 @@ static int vars_fill_desc(const char *name, int len, struct var_desc *desc, char
        /* Check variable name syntax. */
        for (tmp = name; tmp < name + len; tmp++) {
                if (!isalnum((unsigned char)*tmp) && *tmp != '_' && *tmp != '.') {
-                       memprintf(err, "invalid syntax at char '%s'", tmp);
+                       memprintf(err, "invalid syntax at char '%c'", *tmp);
                        return 0;
                }
        }