BUG/MEDIUM: vars: make functions vars_get_by_{name,desc} thread-safe
authorDragan Dosen <ddosen@haproxy.com>
Mon, 22 Feb 2021 16:20:01 +0000 (17:20 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 26 Feb 2021 15:54:29 +0000 (16:54 +0100)
commitdd8b4da9e1bd908111a2829d5aadec338d345865
treefa663d1e9bb16b68112f29cb7ed5ddab811e40d6
parentd98c79cefc654720e8123480b9e0229c18847db6
BUG/MEDIUM: vars: make functions vars_get_by_{name,desc} thread-safe

This patch adds a lock to functions vars_get_by_name() and
vars_get_by_desc() to protect accesses to the list of variables.

After the variable is fetched, a sample data is duplicated by using
smp_dup() because the variable may be modified by another thread.

This should be backported to all versions supporting vars along with
"BUG/MINOR: sample: secure convs that accept base64 string and var name
as args" which this patch depends on.

(cherry picked from commit 14518f2305027dfd537c1be0f88350337b5fba23)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit bdea395d630bdb92e5d882e235439a1560e12296)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 6524481ea5ab6ca5888450d535d011046d7d2f80)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/vars.c