]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: catch implicit map expressions without known datatype
authorFlorian Westphal <fw@strlen.de>
Mon, 4 Dec 2023 21:51:21 +0000 (22:51 +0100)
committerFlorian Westphal <fw@strlen.de>
Tue, 5 Dec 2023 11:43:21 +0000 (12:43 +0100)
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>
src/evaluate.c
tests/shell/testcases/bogons/nft-f/mapping_With_invalid_datatype_crash [new file with mode: 0644]

index f05cac416eb8cc4c58fda8ab644529612b11ba39..16ad6473db1ad4da180fc469f4ab6a742bb595b7 100644 (file)
@@ -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 (file)
index 0000000..9f7084c
--- /dev/null
@@ -0,0 +1 @@
+bla to tcp dport map { 80 : 1.1.1.1 . 8001, 81 : 2.2.2.2 . 9001 } bla