All of lore.kernel.org
 help / color / mirror / Atom feed
From: James King <t.james.king@gmail.com>
To: kaber@trash.net
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH][IPTABLES]: libxt_iprange: Fix IP validation logic
Date: Tue, 01 Apr 2008 14:17:36 -0700	[thread overview]
Message-ID: <47F2A670.2000405@gmail.com> (raw)

On iptables 1.4.1 pulled from SVN, the iprange match rejects valid IP addresses:

#iptables -t filter -A INPUT -m iprange --src-range \
192.168.1.1-192.168.1.2 -j ACCEPT
iptables v1.4.1: iprange match: Bad IP address `192.168.1.1'

The validation logic following numeric_to_ipaddr() was inverted.
Compile and rule insert tested.

===
[IPTABLES]: libxt_iprange: Fix IP validation logic

IP address validation logic was inverted, causing valid addresses to
be rejected.

Signed-off-by: James King <t.james.king@gmail.com>
---
diff -uprN a/extensions/libxt_iprange.c b/extensions/libxt_iprange.c
--- a/extensions/libxt_iprange.c        2008-04-01 10:26:51.000000000 -0700
+++ b/extensions/libxt_iprange.c        2008-04-01 10:40:15.000000000 -0700
@@ -41,14 +41,14 @@ parse_iprange(char *arg, struct ipt_ipra
                 *dash = '\0';

         ip = numeric_to_ipaddr(arg);
-       if (ip != NULL)
+       if (!ip)
                 exit_error(PARAMETER_PROBLEM, "iprange match: Bad IP address `%s'\n",
                            arg);
         range->min_ip = ip->s_addr;

         if (dash != NULL) {
                 ip = numeric_to_ipaddr(dash+1);
-               if (ip != NULL)
+               if (!ip)
                         exit_error(PARAMETER_PROBLEM, "iprange match: Bad IP address `%s'\n",
                                    dash+1);
                 range->max_ip = ip->s_addr;

             reply	other threads:[~2008-04-01 21:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-01 21:17 James King [this message]
2008-04-02 10:17 ` [PATCH][IPTABLES]: libxt_iprange: Fix IP validation logic Patrick McHardy

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=47F2A670.2000405@gmail.com \
    --to=t.james.king@gmail.com \
    --cc=kaber@trash.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.