* [PATCH nft] evaluate: catch implicit map expressions without known datatype
@ 2023-12-04 21:54 Florian Westphal
0 siblings, 0 replies; only message in thread
From: Florian Westphal @ 2023-12-04 21:54 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
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 | 4 ++++
.../bogons/nft-f/mapping_With_invalid_datatype_crash | 1 +
2 files changed, 5 insertions(+)
create mode 100644 tests/shell/testcases/bogons/nft-f/mapping_With_invalid_datatype_crash
diff --git a/src/evaluate.c b/src/evaluate.c
index f05cac416eb8..16ad6473db1a 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 000000000000..9f7084c838bb
--- /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
--
2.41.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-12-04 21:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-04 21:54 [PATCH nft] evaluate: catch implicit map expressions without known datatype Florian Westphal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).