diff options
author | Florian Westphal <fw@strlen.de> | 2023-12-04 22:51:21 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-12-12 13:30:09 +0100 |
commit | e8a7bdbd58f57ed46b6979eab3e4f19bfd9d8858 (patch) | |
tree | 9acd99928b53a58c6743df93865ed7cb58742f9e | |
parent | 31d874c2e45958af8f3ed6015d6ab8626ab0e48b (diff) |
evaluate: catch implicit map expressions without known datatype
commit 70054e6e1c879475779d82d19f450ac521700fe4 upstream.
mapping_With_invalid_datatype_crash:1:8-65: Error: Implicit map expression without known datatype
bla to tcp dport map { 80 : 1.1.1.1 . 8001, 81 : 2.2.2.2 . 9001 } bla
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Signed-off-by: Florian Westphal <fw@strlen.de>
-rw-r--r-- | src/evaluate.c | 4 | ||||
-rw-r--r-- | tests/shell/testcases/bogons/nft-f/mapping_With_invalid_datatype_crash | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/evaluate.c b/src/evaluate.c index 639bc012..a5c95426 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -1784,6 +1784,10 @@ static int expr_evaluate_map(struct eval_ctx *ctx, struct expr **expr) ctx->ectx.len, NULL); } + if (!ectx.dtype) + return expr_error(ctx->msgs, map, + "Implicit map expression without known datatype"); + if (ectx.dtype->type == TYPE_VERDICT) { data = verdict_expr_alloc(&netlink_location, 0, NULL); } else { diff --git a/tests/shell/testcases/bogons/nft-f/mapping_With_invalid_datatype_crash b/tests/shell/testcases/bogons/nft-f/mapping_With_invalid_datatype_crash new file mode 100644 index 00000000..9f7084c8 --- /dev/null +++ b/tests/shell/testcases/bogons/nft-f/mapping_With_invalid_datatype_crash @@ -0,0 +1 @@ +bla to tcp dport map { 80 : 1.1.1.1 . 8001, 81 : 2.2.2.2 . 9001 } bla |