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 04/24] libxt_quota: make sure uint64 is not truncated
Date: Wed, 25 May 2011 01:08:05 +0200	[thread overview]
Message-ID: <1306278506-11463-5-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1306278506-11463-1-git-send-email-jengelh@medozas.de>

From: JP Abgrall <jpa@google.com>

The xtables_strtoul() would cram a long long into a long.
The parse_int would try to cram a UINT64 into a long.
---
 include/xtables.h.in |    2 +-
 xtables.c            |    4 ++--
 xtoptions.c          |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/xtables.h.in b/include/xtables.h.in
index f88813f..90eb1b2 100644
--- a/include/xtables.h.in
+++ b/include/xtables.h.in
@@ -408,7 +408,7 @@ extern void xtables_register_matches(struct xtables_match *, unsigned int);
 extern void xtables_register_target(struct xtables_target *me);
 extern void xtables_register_targets(struct xtables_target *, unsigned int);
 
-extern bool xtables_strtoul(const char *, char **, unsigned long *,
+extern bool xtables_strtoul(const char *, char **, unsigned long long *,
 	unsigned long, unsigned long);
 extern bool xtables_strtoui(const char *, char **, unsigned int *,
 	unsigned int, unsigned int);
diff --git a/xtables.c b/xtables.c
index f10cdb7..3c9a13f 100644
--- a/xtables.c
+++ b/xtables.c
@@ -426,7 +426,7 @@ int xtables_load_ko(const char *modprobe, bool quiet)
  * Returns true/false whether number was accepted. On failure, *value has
  * undefined contents.
  */
-bool xtables_strtoul(const char *s, char **end, unsigned long *value,
+bool xtables_strtoul(const char *s, char **end, unsigned long long *value,
                      unsigned long min, unsigned long max)
 {
 	unsigned long v;
@@ -454,7 +454,7 @@ bool xtables_strtoul(const char *s, char **end, unsigned long *value,
 bool xtables_strtoui(const char *s, char **end, unsigned int *value,
                      unsigned int min, unsigned int max)
 {
-	unsigned long v;
+	unsigned long long v;
 	bool ret;
 
 	ret = xtables_strtoul(s, end, &v, min, max);
diff --git a/xtoptions.c b/xtoptions.c
index 3c3ce5f..ec2269b 100644
--- a/xtoptions.c
+++ b/xtoptions.c
@@ -105,7 +105,7 @@ static void xtopt_parse_int(struct xt_option_call *cb)
 {
 	const struct xt_option_entry *entry = cb->entry;
 	unsigned long long lmin = 0, lmax = UINT32_MAX;
-	unsigned int value;
+	unsigned long long value;
 
 	if (entry->type == XTTYPE_UINT8)
 		lmax = UINT8_MAX;
@@ -118,7 +118,7 @@ static void xtopt_parse_int(struct xt_option_call *cb)
 	if (cb->entry->max != 0)
 		lmax = cb->entry->max;
 
-	if (!xtables_strtoui(cb->arg, NULL, &value, lmin, lmax))
+	if (!xtables_strtoul(cb->arg, NULL, &value, lmin, lmax))
 		xt_params->exit_err(PARAMETER_PROBLEM,
 			"%s: bad value for option \"--%s\", "
 			"or out of range (%llu-%llu).\n",
-- 
1.7.3.4


  parent reply	other threads:[~2011-05-24 23:08 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-24 23:08 Doc/Option parser fixes Jan Engelhardt
2011-05-24 23:08 ` [PATCH 01/24] libxtables: retract _NE types and use a flag instead Jan Engelhardt
2011-05-24 23:08 ` [PATCH 02/24] libipt_REDIRECT: "--to-ports" is not mandatory Jan Engelhardt
2011-05-24 23:08 ` [PATCH 03/24] libxt_quota: readd missing XTOPT_PUT request Jan Engelhardt
2011-05-24 23:08 ` Jan Engelhardt [this message]
2011-05-24 23:08 ` [PATCH 05/24] libxtables: check for negative numbers in xtables_strtou* Jan Engelhardt
2011-05-24 23:08 ` [PATCH 06/24] libxt_rateest: streamline case display of units Jan Engelhardt
2011-05-24 23:08 ` [PATCH 07/24] doc: add some coded option examples to libxt_hashlimit Jan Engelhardt
2011-05-24 23:08 ` [PATCH 08/24] doc: make usage of libxt_rateest more obvious Jan Engelhardt
2011-05-24 23:08 ` [PATCH 09/24] doc: clarify that -p all is a special keyword only Jan Engelhardt
2011-05-24 23:08 ` [PATCH 10/24] doc: use .IP list for TCPMSS Jan Engelhardt
2011-05-24 23:08 ` [PATCH 11/24] doc: remove redundant .IP calls in libxt_time Jan Engelhardt
2011-05-24 23:08 ` [PATCH 12/24] libxt_ipvs: restore network-byte order Jan Engelhardt
2011-05-25  0:31   ` Simon Horman
2011-05-24 23:08 ` [PATCH 13/24] libxt_u32: --u32 option is required Jan Engelhardt
2011-05-24 23:08 ` [PATCH 14/24] libip6t_rt: restore --rt-type storing Jan Engelhardt
2011-05-24 23:08 ` [PATCH 15/24] libxtables: more detailed error message on multi-int parsing Jan Engelhardt
2011-05-24 23:08 ` [PATCH 16/24] libxtables: use uintmax for xtables_strtoul Jan Engelhardt
2011-05-24 23:08 ` [PATCH 17/24] libxtables: make multiint parser have greater range Jan Engelhardt
2011-05-24 23:08 ` [PATCH 18/24] libxtables: unclutter xtopt_parse_mint Jan Engelhardt
2011-05-24 23:08 ` [PATCH 19/24] libxtables: have xtopt_parse_mint interpret partially-spec'd ranges Jan Engelhardt
2011-05-24 23:08 ` [PATCH 20/24] libxt_NFQUEUE: avoid double attempt at parsing Jan Engelhardt
2011-05-24 23:08 ` [PATCH 21/24] libxt_NFQUEUE: add mutual exclusion between qnum and qbal Jan Engelhardt
2011-05-24 23:08 ` [PATCH 22/24] libxt_time: always ignore libc timezone Jan Engelhardt
2011-05-24 23:08 ` [PATCH 23/24] libxt_time: --utc and --localtz are mutually exclusive Jan Engelhardt
2011-05-24 23:08 ` [PATCH 24/24] libxt_time: deprecate --localtz option, document kernel TZ caveats Jan Engelhardt
2011-05-25  3:35 ` Doc/Option parser 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=1306278506-11463-5-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).