diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-05-10 15:41:04 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-05-10 15:41:04 -0400 |
commit | c78a42685fd342ec961ede7a61e7b82bd40060b8 (patch) | |
tree | a19fa593d91d84d60d060ee52ff108ad69d8e66e /src/common | |
parent | 1cf970c3dbbdbdf2b2fb162bbeeb6890e9b6c5c4 (diff) | |
parent | 79c4c8195a9da15dc13866dd4a706807c79dba46 (diff) | |
download | tor-c78a42685fd342ec961ede7a61e7b82bd40060b8.tar tor-c78a42685fd342ec961ede7a61e7b82bd40060b8.tar.gz |
Merge remote-tracking branch 'origin/maint-0.2.2'
Conflicts:
src/common/util.c
src/test/test_util.c
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 276c6dd13..30bf6879a 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -870,6 +870,9 @@ tor_digest256_is_zero(const char *digest) /* Helper: common code to check whether the result of a strtol or strtoul or * strtoll is correct. */ #define CHECK_STRTOX_RESULT() \ + /* Did an overflow occur? */ \ + if (errno == ERANGE) \ + goto err; \ /* Was at least one character converted? */ \ if (endptr == s) \ goto err; \ @@ -911,6 +914,8 @@ tor_parse_long(const char *s, int base, long min, long max, *ok = 0; return 0; } + + errno = 0; r = strtol(s, &endptr, base); CHECK_STRTOX_RESULT(); } @@ -928,6 +933,8 @@ tor_parse_ulong(const char *s, int base, unsigned long min, *ok = 0; return 0; } + + errno = 0; r = strtoul(s, &endptr, base); CHECK_STRTOX_RESULT(); } @@ -939,6 +946,7 @@ tor_parse_double(const char *s, double min, double max, int *ok, char **next) char *endptr; double r; + errno = 0; r = strtod(s, &endptr); CHECK_STRTOX_RESULT(); } @@ -958,6 +966,7 @@ tor_parse_uint64(const char *s, int base, uint64_t min, return 0; } + errno = 0; #ifdef HAVE_STRTOULL r = (uint64_t)strtoull(s, &endptr, base); #elif defined(_WIN32) |