]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxtables: Don't read garbage in xtables_strtoui()
authorPhil Sutter <phil@nwl.cc>
Wed, 19 Sep 2018 13:16:55 +0000 (15:16 +0200)
committerFlorian Westphal <fw@strlen.de>
Mon, 24 Sep 2018 09:24:09 +0000 (11:24 +0200)
If xtables_strtoul() fails, it returns false and data pointed to by
parameter 'value' is undefined. Hence avoid copying that data in
xtables_strtoui() if the call failed.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
libxtables/xtables.c

index 1b8e4b074b07880ff843530d4222840e532451b6..ffd8fbcf294658479c61ccacb5c366e253f2672d 100644 (file)
@@ -492,7 +492,7 @@ bool xtables_strtoui(const char *s, char **end, unsigned int *value,
        bool ret;
 
        ret = xtables_strtoul(s, end, &v, min, max);
-       if (value != NULL)
+       if (ret && value != NULL)
                *value = v;
        return ret;
 }