From: Florian Westphal Date: Mon, 4 Dec 2023 21:51:21 +0000 (+0100) Subject: evaluate: catch implicit map expressions without known datatype X-Git-Tag: v1.0.6.1~312 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e8a7bdbd58f57ed46b6979eab3e4f19bfd9d8858;p=thirdparty%2Fnftables.git 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 --- 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