diff options
author | Pablo M. Bermudo Garay <pablombg@gmail.com> | 2016-07-09 12:27:51 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-07-09 13:44:46 +0200 |
commit | f035be35c749d5c5cbb7ffdbcd1c548b91bd3033 (patch) | |
tree | 69f5402722a70645f783d761e2ec60a4e99a85e1 /extensions/libxt_sctp.c | |
parent | e8f857a5a1514c3e7d0d8ea0f7d2d571f0e37bd1 (diff) |
xtables-translate: fix multiple spaces issue
This patch fixes a multiple spaces issue. The problem arises when a rule
set loaded through iptables-compat-restore is listed in nft.
Before this commit, two spaces were printed after every match
translation:
$ sudo iptables-save
*filter
:INPUT ACCEPT [0:0]
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m multiport --dports 80:85 -m ttl --ttl-gt 5 -j ACCEPT
COMMIT
$ sudo iptables-compat-restore iptables-save
$ sudo nft list ruleset
table ip filter {
chain INPUT {
type filter hook input priority 0; policy accept;
ct state related,established counter packets 0 bytes 0 accept
^^
ip protocol tcp tcp dport 80-85 ip ttl gt 5 counter packets 0 bytes 0 accept
^^ ^^
}
}
Signed-off-by: Pablo M. Bermudo Garay <pablombg@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'extensions/libxt_sctp.c')
-rw-r--r-- | extensions/libxt_sctp.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/extensions/libxt_sctp.c b/extensions/libxt_sctp.c index ae1969a0..a04b4fc0 100644 --- a/extensions/libxt_sctp.c +++ b/extensions/libxt_sctp.c @@ -490,6 +490,7 @@ static int sctp_xlate(const void *ip, const struct xt_entry_match *match, { const struct xt_sctp_info *einfo = (const struct xt_sctp_info *)match->data; + char *space = ""; if (!einfo->flags) return 0; @@ -498,22 +499,23 @@ static int sctp_xlate(const void *ip, const struct xt_entry_match *match, if (einfo->flags & XT_SCTP_SRC_PORTS) { if (einfo->spts[0] != einfo->spts[1]) - xt_xlate_add(xl, "sport%s %u-%u ", + xt_xlate_add(xl, "sport%s %u-%u", einfo->invflags & XT_SCTP_SRC_PORTS ? " !=" : "", einfo->spts[0], einfo->spts[1]); else - xt_xlate_add(xl, "sport%s %u ", + xt_xlate_add(xl, "sport%s %u", einfo->invflags & XT_SCTP_SRC_PORTS ? " !=" : "", einfo->spts[0]); + space = " "; } if (einfo->flags & XT_SCTP_DEST_PORTS) { if (einfo->dpts[0] != einfo->dpts[1]) - xt_xlate_add(xl, "dport%s %u-%u ", + xt_xlate_add(xl, "%sdport%s %u-%u", space, einfo->invflags & XT_SCTP_DEST_PORTS ? " !=" : "", einfo->dpts[0], einfo->dpts[1]); else - xt_xlate_add(xl, "dport%s %u ", + xt_xlate_add(xl, "%sdport%s %u", space, einfo->invflags & XT_SCTP_DEST_PORTS ? " !=" : "", einfo->dpts[0]); } |