summaryrefslogtreecommitdiff
path: root/src/rust/protover/protover.rs
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-10-14 11:28:37 -0400
committerNick Mathewson <nickm@torproject.org>2020-10-14 11:28:37 -0400
commitdd63b972883f6c0b23ee2f7661b7897b229dd28f (patch)
tree58d3a6bedb61dc9fcc8f1c1a99f2a170fa96e4f8 /src/rust/protover/protover.rs
parent741edf1b458f56f516a02aa72bfae99371b3ec5a (diff)
downloadtor-dd63b972883f6c0b23ee2f7661b7897b229dd28f.tar.gz
tor-dd63b972883f6c0b23ee2f7661b7897b229dd28f.zip
Implement proposal 318: Limit protovers to 0..63
In brief: we go through a lot of gymnastics to handle huge protover numbers, but after years of development we're not even close to 10 for any of our current versions. We also have a convenient workaround available in case we ever run out of protocols: if (for example) we someday need Link=64, we can just add Link2=0 or something. This patch is a minimal patch to change tor's behavior; it doesn't take advantage of the new restrictions. Implements #40133 and proposal 318.
Diffstat (limited to 'src/rust/protover/protover.rs')
-rw-r--r--src/rust/protover/protover.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/rust/protover/protover.rs b/src/rust/protover/protover.rs
index 06fdf56c69..536667f61b 100644
--- a/src/rust/protover/protover.rs
+++ b/src/rust/protover/protover.rs
@@ -866,12 +866,12 @@ mod test {
#[test]
fn test_protoentry_from_str_allowed_number_of_versions() {
- assert_protoentry_is_parseable!("Desc=1-4294967294");
+ assert_protoentry_is_parseable!("Desc=1-63");
}
#[test]
fn test_protoentry_from_str_too_many_versions() {
- assert_protoentry_is_unparseable!("Desc=1-4294967295");
+ assert_protoentry_is_unparseable!("Desc=1-64");
}
#[test]
@@ -910,10 +910,10 @@ mod test {
#[test]
fn test_protoentry_all_supported_unsupported_high_version() {
- let protocols: UnvalidatedProtoEntry = "HSDir=12-100".parse().unwrap();
+ let protocols: UnvalidatedProtoEntry = "HSDir=12-60".parse().unwrap();
let unsupported: Option<UnvalidatedProtoEntry> = protocols.all_supported();
assert_eq!(true, unsupported.is_some());
- assert_eq!("HSDir=12-100", &unsupported.unwrap().to_string());
+ assert_eq!("HSDir=12-60", &unsupported.unwrap().to_string());
}
#[test]
@@ -962,7 +962,7 @@ mod test {
ProtoSet::from_str(&versions).unwrap().to_string()
);
- versions = "1-3,500";
+ versions = "1-3,50";
assert_eq!(
String::from(versions),
ProtoSet::from_str(&versions).unwrap().to_string()