diff options
author | Florian Westphal <fw@strlen.de> | 2023-12-04 22:51:21 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2023-12-05 12:43:21 +0100 |
commit | 70054e6e1c879475779d82d19f450ac521700fe4 (patch) | |
tree | 2234afe0a96f3c006c2e512ece6f9572565874e3 | |
parent | 5f43ea807bb0f5b30f332c2c96f13e33c9243d22 (diff) |
evaluate: catch implicit map expressions without known datatype
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 f05cac41..16ad6473 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -1969,6 +1969,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 |