]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/shell: add testcase to catch segfault if invalid syntax was used
authorArturo Borrero <arturo.borrero.glez@gmail.com>
Wed, 11 May 2016 11:30:13 +0000 (13:30 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 13 May 2016 09:35:48 +0000 (11:35 +0200)
This helps to catch 5afa5a1 ("evaluate: check for NULL datatype in rhs
in lookup expr").

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/nft-f/0007action_object_set_segfault_1 [new file with mode: 0755]

diff --git a/tests/shell/testcases/nft-f/0007action_object_set_segfault_1 b/tests/shell/testcases/nft-f/0007action_object_set_segfault_1
new file mode 100755 (executable)
index 0000000..3a4183b
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# test for a segfault if bad syntax was used in set declaration
+# and the set is referenced in the same batch
+
+tmpfile=$(mktemp)
+if [ ! -w $tmpfile ] ; then
+       echo "Failed to create tmp file" >&2
+       exit 0
+fi
+
+trap "rm -f $tmpfile" EXIT # cleanup if aborted
+
+echo "
+add table t
+add chain t c
+add set t s {type ipv4_addr\;}
+add rule t c ip saddr @s
+" > $tmpfile
+
+$NFT -f $tmpfile 2>/dev/null