[iptables PATCH 14/28] libxtables: Don't read garbage in xtables_strtoui()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 libxtables/xtables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index 1b8e4b074b078..ffd8fbcf29465 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;
 }
-- 
2.18.0




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux