summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/sets
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2025-03-10 08:29:37 +0100
committerFlorian Westphal <fw@strlen.de>2025-03-10 10:31:17 +0100
commitf6d9610c86ce6f1b8618611e3c993970760bc03d (patch)
tree93da8063c0b60010f0c77dcce4a55565fdf85ccf /tests/shell/testcases/sets
parent47c4a5ddbb466da165c039de6eefb955509b6439 (diff)
evaluate: don't crash if range has same start and end interval
In this case, evaluation step replaces the range expression with a single value and we'd crash as range->left/right contain garbage values. Simply replace the input expression with the evaluation result. Also add a test case modeled on the afl reproducer. Fixes: fe6cc0ad29cd ("evaluate: consolidate evaluation of symbol range expression") Signed-off-by: Florian Westphal <fw@strlen.de> Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests/shell/testcases/sets')
-rw-r--r--tests/shell/testcases/sets/dumps/range_with_same_start_end.json-nft35
-rw-r--r--tests/shell/testcases/sets/dumps/range_with_same_start_end.nft7
-rwxr-xr-xtests/shell/testcases/sets/range_with_same_start_end13
3 files changed, 55 insertions, 0 deletions
diff --git a/tests/shell/testcases/sets/dumps/range_with_same_start_end.json-nft b/tests/shell/testcases/sets/dumps/range_with_same_start_end.json-nft
new file mode 100644
index 00000000..c4682475
--- /dev/null
+++ b/tests/shell/testcases/sets/dumps/range_with_same_start_end.json-nft
@@ -0,0 +1,35 @@
+{
+ "nftables": [
+ {
+ "metainfo": {
+ "version": "VERSION",
+ "release_name": "RELEASE_NAME",
+ "json_schema_version": 1
+ }
+ },
+ {
+ "table": {
+ "family": "ip",
+ "name": "t",
+ "handle": 0
+ }
+ },
+ {
+ "set": {
+ "family": "ip",
+ "name": "X",
+ "table": "t",
+ "type": "inet_service",
+ "handle": 0,
+ "flags": [
+ "interval"
+ ],
+ "elem": [
+ 10,
+ 30,
+ 35
+ ]
+ }
+ }
+ ]
+}
diff --git a/tests/shell/testcases/sets/dumps/range_with_same_start_end.nft b/tests/shell/testcases/sets/dumps/range_with_same_start_end.nft
new file mode 100644
index 00000000..78979e9e
--- /dev/null
+++ b/tests/shell/testcases/sets/dumps/range_with_same_start_end.nft
@@ -0,0 +1,7 @@
+table ip t {
+ set X {
+ type inet_service
+ flags interval
+ elements = { 10, 30, 35 }
+ }
+}
diff --git a/tests/shell/testcases/sets/range_with_same_start_end b/tests/shell/testcases/sets/range_with_same_start_end
new file mode 100755
index 00000000..127f0921
--- /dev/null
+++ b/tests/shell/testcases/sets/range_with_same_start_end
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+set -e
+
+$NFT -f - <<EOF
+table ip t {
+ set X {
+ type inet_service
+ flags interval
+ elements = { 10, 30-30, 30, 35 }
+ }
+}
+EOF