From: Phil Sutter Date: Wed, 19 Sep 2018 13:16:55 +0000 (+0200) Subject: libxtables: Don't read garbage in xtables_strtoui() X-Git-Tag: v1.8.1~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61ebf3f72ac62d887414c50fc83e277386f54e8f;p=thirdparty%2Fiptables.git libxtables: Don't read garbage in xtables_strtoui() 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 Signed-off-by: Florian Westphal --- diff --git a/libxtables/xtables.c b/libxtables/xtables.c index 1b8e4b07..ffd8fbcf 100644 --- a/libxtables/xtables.c +++ b/libxtables/xtables.c @@ -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; }