]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: variables: some variable name can hide another ones
authorThierry FOURNIER / OZON.IO <thierry.fournier@ozon.io>
Mon, 12 Dec 2016 11:42:14 +0000 (12:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 12 Dec 2016 13:34:56 +0000 (14:34 +0100)
The variable are compared only using text, the final '\0' (or the
string length) are not checked. So, the variable name "txn.internal"
matchs other one call "txn.int".

This patch fix this behavior

It must be backported ni 1.6 and 1.7

src/vars.c

index 4d18a4fd8fe2e3cc3473a3952699c476d7bb9758..e5448e526ba9ec54f49d4adb9c8c2b1f2a0ce3fc 100644 (file)
@@ -201,7 +201,7 @@ static char *register_name(const char *name, int len, enum vars_scope *scope,
 
        /* Look for existing variable name. */
        for (i = 0; i < var_names_nb; i++)
-               if (strncmp(var_names[i], name, len) == 0)
+               if (strncmp(var_names[i], name, len) == 0 && var_names[i][len] == '\0')
                        return var_names[i];
 
        if (!alloc)