]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables: Fix for matching rules with wildcard interfaces
authorPhil Sutter <phil@nwl.cc>
Wed, 31 Oct 2018 19:13:34 +0000 (20:13 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 31 Oct 2018 23:20:59 +0000 (00:20 +0100)
Due to xtables_parse_interface() and parse_ifname() being misaligned
regarding interface mask setting, rules containing a wildcard interface
added with iptables-nft could neither be checked nor deleted.

As suggested, introduce extensions/iptables.t to hold checks for
built-in selectors. This file is picked up by iptables-test.py as-is.
The only limitation is that iptables is being used for it, so no
ip6tables-specific things can be tested with it (for now).

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
extensions/iptables.t [new file with mode: 0644]
iptables/nft-shared.c

diff --git a/extensions/iptables.t b/extensions/iptables.t
new file mode 100644 (file)
index 0000000..65456ee
--- /dev/null
@@ -0,0 +1,4 @@
+:FORWARD
+-i alongifacename0;=;OK
+-i thisinterfaceistoolong0;;FAIL
+-i eth+ -o alongifacename+;=;OK
index 492e4ec124a79c6d546b50cba387294f7d766d2c..7b8ca5e4becaf0adb5910a7a52673bd28c4ae534 100644 (file)
@@ -249,7 +249,7 @@ static void parse_ifname(const char *name, unsigned int len, char *dst, unsigned
                return;
        dst[len++] = 0;
        if (mask)
-               memset(mask, 0xff, len + 1);
+               memset(mask, 0xff, len - 2);
 }
 
 int parse_meta(struct nftnl_expr *e, uint8_t key, char *iniface,