]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxt_devgroup: guard against negative numbers
authorJan Engelhardt <jengelh@inai.de>
Fri, 13 Jul 2012 22:06:45 +0000 (00:06 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 31 Jul 2012 11:32:15 +0000 (13:32 +0200)
More corrections of the strtoul kind.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
extensions/libxt_devgroup.c

index 69ae279d4401fc79b574ef81879bb96cef543d20..4a69c8229ce4ad019837acd124296e9685741941 100644 (file)
@@ -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 {