]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: vars: Fix the set-var and unset-var converters
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Fri, 26 Nov 2021 17:08:39 +0000 (18:08 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 1 Dec 2021 09:32:19 +0000 (10:32 +0100)
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.

src/vars.c

index a61fb12338d890b043dbcf07b9678113630e61dc..f96bb27a96c11b5d0bf119bb650711d6870e6212 100644 (file)
@@ -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