netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Engelhardt <jengelh@inai.de>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 5/7] libxt_devgroup: guard against negative numbers
Date: Sat, 28 Jul 2012 19:21:07 +0200	[thread overview]
Message-ID: <1343496069-5442-6-git-send-email-jengelh@inai.de> (raw)
In-Reply-To: <1343496069-5442-1-git-send-email-jengelh@inai.de>

More corrections of the strtoul kind.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
---
 extensions/libxt_devgroup.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/extensions/libxt_devgroup.c b/extensions/libxt_devgroup.c
index 69ae279..4a69c82 100644
--- a/extensions/libxt_devgroup.c
+++ b/extensions/libxt_devgroup.c
@@ -46,14 +46,16 @@ static void devgroup_parse_groupspec(const char *arg, unsigned int *group,
 				     unsigned int *mask)
 {
 	char *end;
+	bool ok;
 
-	*group = strtoul(arg, &end, 0);
-	if (end != arg && (*end == '/' || *end == '\0')) {
+	ok = xtables_strtoui(arg, &end, group, 0, UINT32_MAX);
+	if (ok && (*end == '/' || *end == '\0')) {
 		if (*end == '/')
-			*mask = strtoul(end + 1, &end, 0);
+			ok = xtables_strtoui(end + 1, NULL, mask,
+			                     0, UINT32_MAX);
 		else
 			*mask = ~0U;
-		if (*end != '\0' || end == arg)
+		if (!ok)
 			xtables_error(PARAMETER_PROBLEM,
 				      "Bad group value \"%s\"", arg);
 	} else {
-- 
1.7.7


  parent reply	other threads:[~2012-07-28 17:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-28 17:21 iptables: Mostly Parser Fixes Jan Engelhardt
2012-07-28 17:21 ` [PATCH 1/7] iptables-restore: warn about -t in rule lines Jan Engelhardt
2012-07-31 11:39   ` Pablo Neira Ayuso
2012-07-31 12:13     ` Jan Engelhardt
2012-07-28 17:21 ` [PATCH 2/7] doc: grammatical updates to libxt_SET Jan Engelhardt
2012-07-28 17:21 ` [PATCH 3/7] libxt_u32: do bounds checking for @'s operands Jan Engelhardt
2012-07-28 17:21 ` [PATCH 4/7] libxt_devgroup: consolidate devgroup specification parsing Jan Engelhardt
2012-07-28 17:21 ` Jan Engelhardt [this message]
2012-07-28 17:21 ` [PATCH 6/7] libxt_LED: guard against negative numbers Jan Engelhardt
2012-07-28 17:21 ` [PATCH 7/7] libxt_*limit: avoid division by zero Jan Engelhardt
2012-07-31 11:40 ` iptables: Mostly Parser Fixes 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=1343496069-5442-6-git-send-email-jengelh@inai.de \
    --to=jengelh@inai.de \
    --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).