aboutsummaryrefslogtreecommitdiff
path: root/src/rust/protover/tests/protover.rs
diff options
context:
space:
mode:
authorcypherpunks <cypherpunks@torproject.org>2018-08-09 21:26:10 +0000
committercypherpunks <cypherpunks@torproject.org>2018-09-14 15:08:55 +0000
commitc613d5513491861431c2852cf4072ae256ba2c67 (patch)
tree97e1d8e1ef58f56cf129ec10f00ddbf7119a5979 /src/rust/protover/tests/protover.rs
parent578f7326eda7307c420286c01b57f71925901533 (diff)
downloadtor-c613d5513491861431c2852cf4072ae256ba2c67.tar.gz
tor-c613d5513491861431c2852cf4072ae256ba2c67.zip
rust/protover: use .and_not_in() instead of .retain() in all_supported()
.retain() would allocating a Vec of billions of integers and check them one at a time to separate the supported versions from the unsupported. This leads to a memory DoS. Closes ticket 27206. Bugfix on e6625113c98c281b0a649598d7daa347c28915e9.
Diffstat (limited to 'src/rust/protover/tests/protover.rs')
-rw-r--r--src/rust/protover/tests/protover.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/rust/protover/tests/protover.rs b/src/rust/protover/tests/protover.rs
index 59a4b5a8a0..9258d869d7 100644
--- a/src/rust/protover/tests/protover.rs
+++ b/src/rust/protover/tests/protover.rs
@@ -354,18 +354,18 @@ fn protover_all_supported_should_exclude_some_versions_and_entire_protocols() {
#[test]
fn protover_all_supported_should_not_dos_anyones_computer() {
- let proto: UnvalidatedProtoEntry = "Sleen=1-2147483648".parse().unwrap();
+ let proto: UnvalidatedProtoEntry = "Link=1-2147483648".parse().unwrap();
let result: String = proto.all_supported().unwrap().to_string();
- assert_eq!(result, "Sleen=1-2147483648".to_string());
+ assert_eq!(result, "Link=6-2147483648".to_string());
}
#[test]
fn protover_all_supported_should_not_dos_anyones_computer_max_versions() {
- let proto: UnvalidatedProtoEntry = "Sleen=1-4294967294".parse().unwrap();
+ let proto: UnvalidatedProtoEntry = "Link=1-4294967294".parse().unwrap();
let result: String = proto.all_supported().unwrap().to_string();
- assert_eq!(result, "Sleen=1-4294967294".to_string());
+ assert_eq!(result, "Link=6-4294967294".to_string());
}
#[test]