]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: threads/vars: Fix deadlock in register_name
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 8 Dec 2017 08:17:39 +0000 (09:17 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 8 Dec 2017 09:37:24 +0000 (10:37 +0100)
In register_name, before locking the var_names array, we check the variable name
validity. So if we try to register an invalid or empty name, we need to return
without unlocking it (because it was never locked).

This patch must be backported in 1.8.

src/vars.c

index c8aa5ac897a9e42816f5ac27c7746c44969c2ece..566ead6ec1ad48cf701eed22193d07ed4e7a3250 100644 (file)
@@ -174,8 +174,7 @@ static char *register_name(const char *name, int len, enum vars_scope *scope,
        /* Check length. */
        if (len == 0) {
                memprintf(err, "Empty variable name cannot be accepted");
-               res = NULL;
-               goto end;
+               return res;
        }
 
        /* Check scope. */
@@ -207,8 +206,7 @@ static char *register_name(const char *name, int len, enum vars_scope *scope,
        else {
                memprintf(err, "invalid variable name '%s'. A variable name must be start by its scope. "
                               "The scope can be 'proc', 'sess', 'txn', 'req' or 'res'", name);
-               res = NULL;
-               goto end;
+               return res;
        }
 
        if (alloc)