diff options
author | Martin Josefsson <gandalf@wlug.westbo.se> | 2004-05-26 15:54:49 +0000 |
---|---|---|
committer | Martin Josefsson <gandalf@wlug.westbo.se> | 2004-05-26 15:54:49 +0000 |
commit | b105bc9f4bf61ffa835950c3d4e4b6162e1e16f8 (patch) | |
tree | a3a34c099e170849facffa83f4c08561619fb7a7 /iptables.c | |
parent | 1da399c30a2c42490f1c6cb84857e31522546c9d (diff) | |
download | platform_external_iptables-b105bc9f4bf61ffa835950c3d4e4b6162e1e16f8.tar.gz platform_external_iptables-b105bc9f4bf61ffa835950c3d4e4b6162e1e16f8.tar.bz2 platform_external_iptables-b105bc9f4bf61ffa835950c3d4e4b6162e1e16f8.zip |
Add versions of string_to_number() for use in 32bit userspace with 64bit kernel.
Diffstat (limited to 'iptables.c')
-rw-r--r-- | iptables.c | 35 |
1 files changed, 30 insertions, 5 deletions
@@ -900,18 +900,18 @@ mask_to_dotted(const struct in_addr *mask) } int -string_to_number(const char *s, unsigned int min, unsigned int max, - unsigned int *ret) +string_to_number_ll(const char *s, unsigned long long min, unsigned long long max, + unsigned long long *ret) { - long number; + unsigned long long number; char *end; /* Handle hex, octal, etc. */ errno = 0; - number = strtol(s, &end, 0); + number = strtoull(s, &end, 0); if (*end == '\0' && end != s) { /* we parsed a number, let's see if we want this */ - if (errno != ERANGE && min <= number && number <= max) { + if (errno != ERANGE && min <= number && (!max || number <= max)) { *ret = number; return 0; } @@ -919,6 +919,31 @@ string_to_number(const char *s, unsigned int min, unsigned int max, return -1; } +int +string_to_number_l(const char *s, unsigned long min, unsigned long max, + unsigned long *ret) +{ + int result; + unsigned long long number; + + result = string_to_number_ll(s, min, max, &number); + *ret = (unsigned long)number; + + return result; +} + +int string_to_number(const char *s, unsigned int min, unsigned int max, + unsigned int *ret) +{ + int result; + unsigned long number; + + result = string_to_number_l(s, min, max, &number); + *ret = (unsigned int)number; + + return result; +} + static void set_option(unsigned int *options, unsigned int option, u_int8_t *invflg, int invert) |