aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-05-10 15:41:04 -0400
committerNick Mathewson <nickm@torproject.org>2012-05-10 15:41:04 -0400
commitc78a42685fd342ec961ede7a61e7b82bd40060b8 (patch)
treea19fa593d91d84d60d060ee52ff108ad69d8e66e /src/test/test_util.c
parent1cf970c3dbbdbdf2b2fb162bbeeb6890e9b6c5c4 (diff)
parent79c4c8195a9da15dc13866dd4a706807c79dba46 (diff)
downloadtor-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/test/test_util.c')
-rw-r--r--src/test/test_util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 7a455e06a..e8f043a2c 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -755,6 +755,21 @@ test_util_strmisc(void)
test_eq(-10.0, d);
}
+ {
+ /* Test tor_parse_* where we overflow/underflow the underlying type. */
+ /* This string should overflow 64-bit ints. */
+#define TOOBIG "100000000000000000000000000"
+ test_eq(0L, tor_parse_long(TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL));
+ test_eq(i, 0);
+ test_eq(0L, tor_parse_long("-"TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL));
+ test_eq(i, 0);
+ test_eq(0UL, tor_parse_ulong(TOOBIG, 10, 0, ULONG_MAX, &i, NULL));
+ test_eq(i, 0);
+ test_eq(U64_LITERAL(0), tor_parse_uint64(TOOBIG, 10,
+ 0, UINT64_MAX, &i, NULL));
+ test_eq(i, 0);
+ }
+
/* Test snprintf */
/* Returning -1 when there's not enough room in the output buffer */
test_eq(-1, tor_snprintf(buf, 0, "Foo"));