diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-11-22 20:35:07 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-11-27 12:54:51 +0100 |
commit | 208a428a63d9292adc589ed8f6f11f561baddb65 (patch) | |
tree | 8d2febc4e87c0a3c6c0fb70a7c84fc26ae169eb0 | |
parent | f7e50d965735636ab932e5280a3d562629a6a58b (diff) |
evaluate: clone unary expression datatype to deal with dynamic datatype
upstream faa6908fad6053ae9549c45b88d0402cc69cf1ed commit.
When allocating a unary expression, clone the datatype to deal with
dynamic datatypes.
Fixes: 6b01bb9ff798 ("datatype: concat expression only releases dynamically allocated datatype")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | src/evaluate.c | 2 | ||||
-rw-r--r-- | tests/shell/testcases/maps/dumps/vmap_unary.nft | 11 | ||||
-rwxr-xr-x | tests/shell/testcases/maps/vmap_unary | 17 |
3 files changed, 29 insertions, 1 deletions
diff --git a/src/evaluate.c b/src/evaluate.c index bc270416..bdd7d458 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -1127,7 +1127,7 @@ static int expr_evaluate_unary(struct eval_ctx *ctx, struct expr **expr) BUG("invalid unary operation %u\n", unary->op); } - unary->dtype = arg->dtype; + unary->dtype = dtype_clone(arg->dtype); unary->byteorder = byteorder; unary->len = arg->len; return 0; diff --git a/tests/shell/testcases/maps/dumps/vmap_unary.nft b/tests/shell/testcases/maps/dumps/vmap_unary.nft new file mode 100644 index 00000000..46c538b7 --- /dev/null +++ b/tests/shell/testcases/maps/dumps/vmap_unary.nft @@ -0,0 +1,11 @@ +table ip filter { + map ipsec_in { + typeof ipsec in reqid . iif : verdict + flags interval + } + + chain INPUT { + type filter hook input priority filter; policy drop; + ipsec in reqid . iif vmap @ipsec_in + } +} diff --git a/tests/shell/testcases/maps/vmap_unary b/tests/shell/testcases/maps/vmap_unary new file mode 100755 index 00000000..4038d1c1 --- /dev/null +++ b/tests/shell/testcases/maps/vmap_unary @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +RULESET="table ip filter { + map ipsec_in { + typeof ipsec in reqid . iif : verdict + flags interval + } + + chain INPUT { + type filter hook input priority 0; policy drop + ipsec in reqid . iif vmap @ipsec_in + } +}" + +$NFT -f - <<< $RULESET |