]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: vars: truncate the variable name in error reports about scope.
authorWilly Tarreau <w@1wt.eu>
Fri, 3 Sep 2021 08:12:55 +0000 (10:12 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Sep 2021 09:01:12 +0000 (11:01 +0200)
When a variable starts with the wrong scope, it is named without stripping
the extra characters that follow it, which usually are closing parenthesis.
Let's make sure we only report what is expected.

This may be backported to 2.4.

src/vars.c

index 85c6fc4bdd0270232cc96b6ed8063173fbbd70b9..e4e547afd2d1cae7d56b0817ea7ba1a9db135d71 100644 (file)
@@ -261,8 +261,8 @@ static char *register_name(const char *name, int len, enum vars_scope *scope,
                *scope = SCOPE_CHECK;
        }
        else {
-               memprintf(err, "invalid variable name '%s'. A variable name must be start by its scope. "
-                              "The scope can be 'proc', 'sess', 'txn', 'req', 'res' or 'check'", name);
+               memprintf(err, "invalid variable name '%.*s'. A variable name must be start by its scope. "
+                              "The scope can be 'proc', 'sess', 'txn', 'req', 'res' or 'check'", len, name);
                return res;
        }