blob: a41d8205015db396ac41753e9c7560107498a4c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#![no_main]
use libfuzzer_sys::fuzz_target;
use tor_general_addr::general;
fuzz_target!(|addr: general::SocketAddr| {
// There is no encoding for flowinfo, so we have to clear it.
let mut addr = addr;
match &mut addr {
general::SocketAddr::Inet(std::net::SocketAddr::V6(v6)) => v6.set_flowinfo(0),
_ => {}
}
if let Some(encoded) = addr.try_to_string() {
let parsed: general::SocketAddr = encoded.parse().unwrap();
assert_eq!(addr, parsed);
// Since this was encodeable, its lossy encoding should be the same.
assert_eq!(encoded, format!("{}", addr.display_lossy()))
}
});
|