From: Phil Oester <kernel@linuxace.com>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org
Subject: [PATCH] iptables: xtables_ipmask_to_numeric incorrect with non-CIDR masks
Date: Thu, 26 Sep 2013 09:06:58 -0700 [thread overview]
Message-ID: <20130926160658.GA12333@home> (raw)
[-- Attachment #1: Type: text/plain, Size: 470 bytes --]
As pointed out by Peter Hoelsken, rules created with non-standard masks such as
0.255.0.0, 0.0.255.0, etc. are displayed when output with iptables -L in CIDR
notation as -1. This is because the cidr variable in xtables_ipmask_to_numeric
is unsigned, and the return value of -1 from xtables_ipmask_to_cidr is therefore
converted to 4294967295. Add a cast to workaround the issue.
This closes netfilter bugzilla #854.
Signed-off-by: Phil Oester <kernel@linuxace.com>
[-- Attachment #2: patch-ipt-cidr --]
[-- Type: text/plain, Size: 469 bytes --]
diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index ef5bc07..8437baf 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -1243,7 +1243,7 @@ const char *xtables_ipmask_to_numeric(const struct in_addr *mask)
uint32_t cidr;
cidr = xtables_ipmask_to_cidr(mask);
- if (cidr < 0) {
+ if (cidr == (unsigned int)-1) {
/* mask was not a decent combination of 1's and 0's */
sprintf(buf, "/%s", xtables_ipaddr_to_numeric(mask));
return buf;
next reply other threads:[~2013-09-26 16:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-26 16:06 Phil Oester [this message]
2013-09-27 14:30 ` [PATCH] iptables: xtables_ipmask_to_numeric incorrect with non-CIDR masks Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130926160658.GA12333@home \
--to=kernel@linuxace.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).