]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: don't crash if object map does not refer to a value
authorFlorian Westphal <fw@strlen.de>
Wed, 20 Dec 2023 10:06:04 +0000 (11:06 +0100)
committerFlorian Westphal <fw@strlen.de>
Wed, 20 Dec 2023 10:22:13 +0000 (11:22 +0100)
Before:
BUG: Value export of 512 bytes would overflownft: src/netlink.c:474: netlink_gen_prefix: Assertion `0' failed.

After:
66: Error: Object mapping data should be a value, not prefix
synproxy name ip saddr map { 192.168.1.0/24 : "v*" }

Signed-off-by: Florian Westphal <fw@strlen.de>
src/evaluate.c
tests/shell/testcases/bogons/nft-f/objmap_to_prefix_assert [new file with mode: 0644]

index 5ddbde42c360b30a2e502fc99ef26edf0cd870ca..26f0110f66ea5dbc4ce11c544248f2032a1688cc 100644 (file)
@@ -2140,6 +2140,11 @@ static int expr_evaluate_mapping(struct eval_ctx *ctx, struct expr **expr)
                return expr_error(ctx->msgs, mapping->right,
                                  "Value must be a singleton");
 
+       if (set_is_objmap(set->flags) && mapping->right->etype != EXPR_VALUE)
+               return expr_error(ctx->msgs, mapping->right,
+                                 "Object mapping data should be a value, not %s",
+                                 expr_name(mapping->right));
+
        mapping->flags |= EXPR_F_CONSTANT;
        return 0;
 }
diff --git a/tests/shell/testcases/bogons/nft-f/objmap_to_prefix_assert b/tests/shell/testcases/bogons/nft-f/objmap_to_prefix_assert
new file mode 100644 (file)
index 0000000..d880a37
--- /dev/null
@@ -0,0 +1,6 @@
+table t {
+        chain y {
+                type filter hook input priority filter; policy accept;
+                synproxy name ip saddr map { 192.168.1.0/24 : "x*" }
+        }
+}