]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: clear expression context before cmd evaluation
authorFlorian Westphal <fw@strlen.de>
Thu, 19 Apr 2018 16:18:57 +0000 (18:18 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 19 Apr 2018 19:17:49 +0000 (21:17 +0200)
We also need to clear expr ctx before we eval a command.
This is a followup fix to 'evaluate: reset eval context when evaluating
set definitions'.

The first patch only fixed set evaluation when dealing with
a complete table representation rather than individual commands.

Reported-by: David Fabian <david.fabian@bosson.cz>
Signed-off-by: Florian Westphal <fw@strlen.de>
src/evaluate.c
tests/shell/testcases/sets/0033add_set_simple_flat_0 [new file with mode: 0755]

index aee5b1c15c7a93cf2ec0c28e02812c08695571fa..265a73fe9b6569441d4b7fedfe53e38b5b2b289b 100644 (file)
@@ -3472,6 +3472,8 @@ int cmd_evaluate(struct eval_ctx *ctx, struct cmd *cmd)
                erec_destroy(erec);
        }
 
+       memset(&ctx->ectx, 0, sizeof(ctx->ectx));
+
        ctx->cmd = cmd;
        switch (cmd->op) {
        case CMD_ADD:
diff --git a/tests/shell/testcases/sets/0033add_set_simple_flat_0 b/tests/shell/testcases/sets/0033add_set_simple_flat_0
new file mode 100755 (executable)
index 0000000..86be0c9
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+RULESET="add table ip x
+add set x setA {type ipv4_addr . inet_service . ipv4_addr; flags timeout;}
+add set x setB {type ipv4_addr . inet_service; flags timeout;}
+"
+
+set -e
+$NFT -f - <<< "$RULESET"