From: Remi Tricot-Le Breton Date: Fri, 26 Nov 2021 17:08:39 +0000 (+0100) Subject: BUG/MINOR: vars: Fix the set-var and unset-var converters X-Git-Tag: v2.6-dev1~346 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bb3e80e1814f63b76f100b342c217d08ca719688;p=thirdparty%2Fhaproxy.git BUG/MINOR: vars: Fix the set-var and unset-var converters In commit 3a4bedccc6 the variable logic was changed. Instead of accessing variables by their name during runtime, the variable tables are now indexed by a hash of the name. But the set-var and unset-var converters try to access the correct variable by calculating a hash on the sample instead of the already calculated variable hash. It should be backported to 2.5. --- diff --git a/src/vars.c b/src/vars.c index a61fb12338..f96bb27a96 100644 --- a/src/vars.c +++ b/src/vars.c @@ -460,19 +460,13 @@ static int var_unset(uint64_t name_hash, enum vars_scope scope, struct sample *s /* Returns 0 if fails, else returns 1. */ static int smp_conv_store(const struct arg *args, struct sample *smp, void *private) { - uint64_t seed = var_name_hash_seed; - uint64_t name_hash = XXH3(smp->data.u.str.area, smp->data.u.str.data, seed); - - return var_set(name_hash, args[0].data.var.scope, smp, 0); + return var_set(args[0].data.var.name_hash, args[0].data.var.scope, smp, 0); } /* Returns 0 if fails, else returns 1. */ static int smp_conv_clear(const struct arg *args, struct sample *smp, void *private) { - uint64_t seed = var_name_hash_seed; - uint64_t name_hash = XXH3(smp->data.u.str.area, smp->data.u.str.data, seed); - - return var_unset(name_hash, args[0].data.var.scope, smp); + return var_unset(args[0].data.var.name_hash, args[0].data.var.scope, smp); } /* This functions check an argument entry and fill it with a variable