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.
This commit is contained in:
Christopher Faulet 2017-12-08 09:17:39 +01:00 committed by Willy Tarreau
parent 1714b9f286
commit eb3e276d39

View 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)