multiaddr: Fix generation of arbitrary onion addr. (#1451)

Exclude port 0 which is not a valid port number for onion addresses.
This commit is contained in:
Toralf Wittner 2020-02-12 20:27:17 +01:00 committed by GitHub
parent e855cd5915
commit afb1c877a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,12 +103,12 @@ impl Arbitrary for Proto {
22 => {
let mut a = [0; 10];
g.fill(&mut a);
Proto(Onion(Cow::Owned(a), g.gen()))
Proto(Onion(Cow::Owned(a), g.gen_range(1, std::u16::MAX)))
},
23 => {
let mut a = [0; 35];
g.fill_bytes(&mut a);
Proto(Onion3((a, g.gen()).into()))
Proto(Onion3((a, g.gen_range(1, std::u16::MAX)).into()))
},
_ => panic!("outside range")
}