From 61ebf3f72ac62d887414c50fc83e277386f54e8f Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Wed, 19 Sep 2018 15:16:55 +0200 Subject: 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 --- libxtables/xtables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- cgit v1.2.3