]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG: vars: Fix 'set-var' converter because of a typo
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 9 Nov 2016 15:15:32 +0000 (16:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 9 Nov 2016 21:50:54 +0000 (22:50 +0100)
The 'set-var' converter uses function smp_conv_store (vars.c). In this function,
we should use the first argument (index 0) to retrieve the variable name and its
scope. But because of a typo, we get the scope of the second argument (index
1). In this case, there is no second argument. So the scope used was always 0
(SCOPE_SESS), always setting the variable in the session scope.

So, due to this bug, this rules

  tcp-request content accept if { src,set-var(txn.foo) -m found }

always set the variable 'sess.foo' instead of 'txn.foo'.

src/vars.c

index 6f9b16aa976f5d1824bb21386ef3d3a775d90225..59c29aa3a0a9ce6aa7e003336b3d76d368332b76 100644 (file)
@@ -379,7 +379,7 @@ static inline int sample_store_stream(const char *name, enum vars_scope scope, s
 /* Returns 0 if fails, else returns 1. */
 static int smp_conv_store(const struct arg *args, struct sample *smp, void *private)
 {
-       return sample_store_stream(args[0].data.var.name, args[1].data.var.scope, smp);
+       return sample_store_stream(args[0].data.var.name, args[0].data.var.scope, smp);
 }
 
 /* This fucntions check an argument entry and fill it with a variable