summaryrefslogtreecommitdiff
path: root/src/rust/protover/tests/protover.rs
diff options
context:
space:
mode:
authorIsis Lovecruft <isis@torproject.org>2018-03-27 22:46:14 +0000
committerIsis Lovecruft <isis@torproject.org>2018-04-02 19:59:16 +0000
commitc65088cb1943748412e1a390de655e20bdb28692 (patch)
treee2808db9bc2b138e89a11c23a52e8e618fe14e51 /src/rust/protover/tests/protover.rs
parent4b4e36a413bb5d0e2ea499dd6bc34b3d24bd3375 (diff)
downloadtor-c65088cb1943748412e1a390de655e20bdb28692.tar.gz
tor-c65088cb1943748412e1a390de655e20bdb28692.zip
rust: Fix ProtoSet and ProtoEntry to use the same DoS limits as C.
Previously, the limit for MAX_PROTOCOLS_TO_EXPAND was actually being applied in Rust to the maximum number of version (total, for all subprotocols). Whereas in C, it was being applied to the number of subprotocols that were allowed. This changes the Rust to match C's behaviour.
Diffstat (limited to 'src/rust/protover/tests/protover.rs')
-rw-r--r--src/rust/protover/tests/protover.rs14
1 files changed, 0 insertions, 14 deletions
diff --git a/src/rust/protover/tests/protover.rs b/src/rust/protover/tests/protover.rs
index 11015f35b4..2db01a1634 100644
--- a/src/rust/protover/tests/protover.rs
+++ b/src/rust/protover/tests/protover.rs
@@ -353,13 +353,6 @@ fn protover_all_supported_should_exclude_some_versions_and_entire_protocols() {
}
#[test]
-#[should_panic(expected = "called `Result::unwrap()` on an `Err` value: ExceedsMax")]
-// C_RUST_DIFFERS: This test fails in Rust (but not in C) because an
-// UnvalidatedProtoEntry is defined as a Hashmap<UnknownProtocol, ProtoSet>.
-// Because it contains the ProtoSet part, there's still *some* validation
-// happening, so in this case the DoS protections in the Rust code are kicking
-// in because the range here is exceeds the maximum, so it returns an
-// Err(ProtoverError::ExceedsMax). The C, however seems to parse it anyway.
fn protover_all_supported_should_not_dos_anyones_computer() {
let proto: UnvalidatedProtoEntry = "Sleen=0-2147483648".parse().unwrap();
let result: String = proto.all_supported().unwrap().to_string();
@@ -368,13 +361,6 @@ fn protover_all_supported_should_not_dos_anyones_computer() {
}
#[test]
-#[should_panic(expected = "called `Result::unwrap()` on an `Err` value: ExceedsMax")]
-// C_RUST_DIFFERS: This test fails in Rust (but not in C) because an
-// UnvalidatedProtoEntry is defined as a Hashmap<UnknownProtocol, ProtoSet>.
-// Because it contains the ProtoSet part, there's still *some* validation
-// happening, so in this case the DoS protections in the Rust code are kicking
-// in because the range here is exceeds the maximum, so it returns an
-// Err(ProtoverError::ExceedsMax). The C, however seems to parse it anyway.
fn protover_all_supported_should_not_dos_anyones_computer_max_versions() {
let proto: UnvalidatedProtoEntry = "Sleen=0-4294967294".parse().unwrap();
let result: String = proto.all_supported().unwrap().to_string();