diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2011-05-20 16:26:04 +0200 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2011-05-20 16:56:50 +0200 |
commit | d61b02fbbbe7f6e643aad8649c8559c175c68c52 (patch) | |
tree | 85d6503e3434c1f9732b3367668c7985a959187a | |
parent | 2305d5fb42fc059f38fc1bdf53411dbeecdb310b (diff) |
libxtables: check for negative numbers in xtables_strtou*
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
-rw-r--r-- | xtables.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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 <ctype.h> #include <errno.h> #include <fcntl.h> #include <netdb.h> @@ -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) |