diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-02-15 09:05:55 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-03-01 16:05:17 -0500 |
commit | 1fe0bae508120bbf4954de6b590dd0c722a883bc (patch) | |
tree | dfbadd8c8d1bb8bdf4b56f509cae9baa93396817 /src/test | |
parent | 8b405c609e82fbfb5470967fc4c45165c708e72b (diff) | |
download | tor-1fe0bae508120bbf4954de6b590dd0c722a883bc.tar.gz tor-1fe0bae508120bbf4954de6b590dd0c722a883bc.zip |
Forbid UINT32_MAX as a protocol version
The C code and the rust code had different separate integer overflow
bugs here. That suggests that we're better off just forbidding this
pathological case.
Also, add tests for expected behavior on receiving a bad protocol
list in a consensus.
Fixes another part of 25249.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_protover.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/test/test_protover.c b/src/test/test_protover.c index 4c41b6db6b..8d061c69ca 100644 --- a/src/test/test_protover.c +++ b/src/test/test_protover.c @@ -257,12 +257,27 @@ test_protover_all_supported(void *arg) tt_str_op(msg, OP_EQ, "Sleen=0-2147483648"); tor_free(msg); - /* Rust seems to experience an internal error here */ - tt_assert(! protover_all_supported("Sleen=0-4294967295", &msg)); - tt_str_op(msg, OP_EQ, "Sleen=0-4294967295"); + /* This case is allowed. */ + tt_assert(! protover_all_supported("Sleen=0-4294967294", &msg)); + tt_str_op(msg, OP_EQ, "Sleen=0-4294967294"); tor_free(msg); + /* If we get an unparseable list, we say "yes, that's supported." */ + tor_capture_bugs_(1); + tt_assert(protover_all_supported("Fribble", &msg)); + tt_ptr_op(msg, OP_EQ, NULL); + tor_end_capture_bugs_(); + + /* This case is forbidden. Since it came from a protover_all_supported, + * it can trigger a bug message. */ + tor_capture_bugs_(1); + tt_assert(protover_all_supported("Sleen=0-4294967295", &msg)); + tt_ptr_op(msg, OP_EQ, NULL); + tor_free(msg); + tor_end_capture_bugs_(); + done: + tor_end_capture_bugs_(); tor_free(msg); } |