netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Engelhardt <jengelh@medozas.de>
To: kaber@trash.net
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 5/7] build: strengthen check for overlong lladdr components
Date: Mon,  8 Aug 2011 02:42:21 +0200	[thread overview]
Message-ID: <1312764144-23849-6-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1312764144-23849-1-git-send-email-jengelh@medozas.de>

ethermac[i] > UINT8_MAX is quite pointless, because ethermac[i] is
just uint8_t. To catch values that are not in the range "00"-"ff", use
a string length check (end-arg>2). I am willingly using 2 there,
because no one is going to specify an Ethernet LL address as
"0x00:0x24:0xbe:0xc2:0x7f:0x16" -- because it is always interpreted as
hexadecimal anyway even without the 0x prefix.

xtoptions.c: In function "xtopt_parse_ethermac":
xtoptions.c:760:3: warning: comparison is always false due to limited range of data type
xtoptions.c:766:2: warning: comparison is always false due to limited range of data type

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
 iptables/xtoptions.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/iptables/xtoptions.c b/iptables/xtoptions.c
index 1423724..7095e3e 100644
--- a/iptables/xtoptions.c
+++ b/iptables/xtoptions.c
@@ -757,13 +757,13 @@ static void xtopt_parse_ethermac(struct xt_option_call *cb)
 
 	for (i = 0; i < ARRAY_SIZE(cb->val.ethermac) - 1; ++i) {
 		cb->val.ethermac[i] = strtoul(arg, &end, 16);
-		if (cb->val.ethermac[i] > UINT8_MAX || *end != ':')
+		if (*end != ':' || end - arg > 2)
 			goto out;
 		arg = end + 1;
 	}
 	i = ARRAY_SIZE(cb->val.ethermac) - 1;
 	cb->val.ethermac[i] = strtoul(arg, &end, 16);
-	if (cb->val.ethermac[i] > UINT8_MAX || *end != '\0')
+	if (*end != '\0' || end - arg > 2)
 		goto out;
 	if (cb->entry->flags & XTOPT_PUT)
 		memcpy(XTOPT_MKPTR(cb), cb->val.ethermac,
-- 
1.7.3.4


  parent reply	other threads:[~2011-08-08  0:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-08  0:42 iptables build fixes Jan Engelhardt
2011-08-08  0:42 ` [PATCH 1/7] extensions: use multi-target registration Jan Engelhardt
2011-08-08  0:42 ` [PATCH 2/7] libxt_TCPMSS: restore build with IPv6-less libcs Jan Engelhardt
2011-08-08  0:42 ` [PATCH 3/7] libxt_string: define _GNU_SOURCE for strnlen Jan Engelhardt
2011-08-08  0:42 ` [PATCH 4/7] build: workaround broken linux-headers on RHEL-5 Jan Engelhardt
2011-08-08  0:42 ` Jan Engelhardt [this message]
2011-08-08  0:42 ` [PATCH 6/7] build: abort autogen on subcommand failure Jan Engelhardt
2011-08-08  0:42 ` [PATCH 7/7] libipq: add pkgconfig file Jan Engelhardt
2011-08-09 11:23 ` iptables build fixes 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=1312764144-23849-6-git-send-email-jengelh@medozas.de \
    --to=jengelh@medozas.de \
    --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 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).