From: Christopher Faulet Date: Fri, 8 Dec 2017 08:17:39 +0000 (+0100) Subject: BUG/MEDIUM: threads/vars: Fix deadlock in register_name X-Git-Tag: v1.9-dev1~598 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb3e276d3911c4c95d1e2f270bab354440378701;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: threads/vars: Fix deadlock in register_name 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. --- diff --git a/src/vars.c b/src/vars.c index c8aa5ac897..566ead6ec1 100644 --- a/src/vars.c +++ b/src/vars.c @@ -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)