]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxt_quota: make sure uint64 is not truncated
authorJP Abgrall <jpa@google.com>
Thu, 19 May 2011 03:26:14 +0000 (20:26 -0700)
committerJan Engelhardt <jengelh@medozas.de>
Fri, 20 May 2011 14:08:27 +0000 (16:08 +0200)
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
xtables.c
xtoptions.c

index f88813f5c78918a8d67e14847f720b2522491c5b..90eb1b2bd833abc657f95e7d9f70931087fe6cb1 100644 (file)
@@ -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);
index f10cdb7075076c3e5f552ce17dc7e403b50d5ddf..3c9a13f4b765545837ba9caeda181f9ff2ceaa05 100644 (file)
--- 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);
index 3c3ce5f1e086545377c5957fef138e915bda8c97..ec2269b2b211805b3fddcef2eaa4772979d3d0b3 100644 (file)
@@ -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",