From d61b02fbbbe7f6e643aad8649c8559c175c68c52 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Fri, 20 May 2011 16:26:04 +0200 Subject: libxtables: check for negative numbers in xtables_strtou* Signed-off-by: Jan Engelhardt --- xtables.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xtables.c b/xtables.c index 3c9a13f4..e11a77ee 100644 --- a/xtables.c +++ b/xtables.c @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - +#include #include #include #include @@ -430,11 +430,16 @@ bool xtables_strtoul(const char *s, char **end, unsigned long long *value, unsigned long min, unsigned long max) { unsigned long v; + const char *p; char *my_end; errno = 0; + /* Since strtoul allows leading minus, we have to check for ourself. */ + for (p = s; isspace(*p); ++p) + ; + if (*p == '-') + return false; v = strtoul(s, &my_end, 0); - if (my_end == s) return false; if (end != NULL) -- cgit v1.2.3