From 94488d4eb912f5af4c88d148b39b38eb8a3c1f0b Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 13 Feb 2020 14:01:50 +0100 Subject: xtables-translate: Fix for iface++ In legacy iptables, only the last plus sign remains special, any previous ones are taken literally. Therefore xtables-translate must not replace all of them with asterisk but just the last one. Fixes: e179e87a1179e ("xtables-translate: Fix for interface name corner-cases") Signed-off-by: Phil Sutter --- iptables/xtables-translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'iptables') diff --git a/iptables/xtables-translate.c b/iptables/xtables-translate.c index c4e177c0..0f95855b 100644 --- a/iptables/xtables-translate.c +++ b/iptables/xtables-translate.c @@ -40,9 +40,6 @@ void xlate_ifname(struct xt_xlate *xl, const char *nftmeta, const char *ifname, for (i = 0, j = 0; i < ifaclen + 1; i++, j++) { switch (ifname[i]) { - case '+': - iface[j] = '*'; - break; case '*': iface[j++] = '\\'; /* fall through */ @@ -65,6 +62,9 @@ void xlate_ifname(struct xt_xlate *xl, const char *nftmeta, const char *ifname, invert = false; } + if (iface[j - 2] == '+') + iface[j - 2] = '*'; + xt_xlate_add(xl, "%s %s\"%s\" ", nftmeta, invert ? "!= " : "", iface); } -- cgit v1.2.3