netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wes Campaigne <westacular@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH 4/4] xtables: use the correct loop count when applying masks to addresses
Date: Mon, 21 Feb 2011 19:10:13 -0500	[thread overview]
Message-ID: <1298333413-14253-5-git-send-email-westacular@gmail.com> (raw)
In-Reply-To: <1298333413-14253-1-git-send-email-westacular@gmail.com>

'n' is a subtotal from the inner loop; 'count' is the total number
of addrs/masks. This problem wasn't merely cosmetic -- rules where
the address has not been zeroed in accordance with the mask are 
silently ignored by netfilter.

Signed-off-by: Wes Campaigne <westacular@gmail.com>
---
 xtables.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/xtables.c b/xtables.c
index c96efa0..f872754 100644
--- a/xtables.c
+++ b/xtables.c
@@ -1272,7 +1272,7 @@ void xtables_ipparse_multiple(const char *name, struct in_addr **addrpp,
 		free(addrp);
 	}
 	*naddrs = count;
-	for (i = 0; i < n; ++i)
+	for (i = 0; i < count; ++i)
 		(*addrpp+i)->s_addr &= (*maskpp+i)->s_addr;
 }
 
@@ -1581,7 +1581,7 @@ xtables_ip6parse_multiple(const char *name, struct in6_addr **addrpp,
 		free(addrp);
 	}
 	*naddrs = count;
-	for (i = 0; i < n; ++i)
+	for (i = 0; i < count; ++i)
 		for (j = 0; j < 4; ++j)
 			(*addrpp+i)->s6_addr32[j] &= (*maskpp+i)->s6_addr32[j];
 }
-- 
1.7.1


  parent reply	other threads:[~2011-02-22  0:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-22  0:10 xtables: various fixes for handling multiple src/dst addresses Wes Campaigne
2011-02-22  0:10 ` [PATCH 1/4] xtables: use *all* IPv6 addresses resolved from a hostname Wes Campaigne
2011-02-22  0:10 ` [PATCH 2/4] xtables: fix excessive memory allocation in host_to_ipaddr Wes Campaigne
2011-02-22  0:10 ` [PATCH 3/4] xtables: fix the broken detection/removal of redundant addresses Wes Campaigne
2011-02-22  0:10 ` Wes Campaigne [this message]
2011-02-22  3:48 ` xtables: various fixes for handling multiple src/dst addresses Jan Engelhardt

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=1298333413-14253-5-git-send-email-westacular@gmail.com \
    --to=westacular@gmail.com \
    --cc=netfilter-devel@vger.kernel.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).