blob: c4509b7e4ac9b16bedcb1a57089c6c3f617e03b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#![no_main]
use libfuzzer_sys::fuzz_target;
use std::str::FromStr;
use tor_general_addr::general;
fuzz_target!(|data: &str| {
if let Ok(addr1) = general::SocketAddr::from_str(data) {
// 1: If we can parse it, we can represent it.
let data2 = addr1.try_to_string().unwrap();
// 2: If we represent it, we can parse it again and get the same thing.
let addr2 = general::SocketAddr::from_str(&data2).unwrap();
assert_eq!(addr1, addr2);
}
});
|