From 699cccb777e9b9094f8b1828061eeb7863aa3db0 Mon Sep 17 00:00:00 2001 From: Remi Tricot-Le Breton Date: Fri, 26 Nov 2021 18:08:39 +0100 Subject: [PATCH] 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. (cherry picked from commit bb3e80e1814f63b76f100b342c217d08ca719688) Signed-off-by: Christopher Faulet --- src/vars.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/vars.c b/src/vars.c index a61fb12..f96bb27 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 -- 1.7.10.4