aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-netdoc/fuzz/fuzz_targets/routers.rs
blob: ed5a5eae5ff79ff101ff897ddd4355c1f1123b8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#![no_main]
use libfuzzer_sys::fuzz_target;
use tor_netdoc::doc::routerdesc::RouterReader;
use tor_netdoc::AllowAnnotations;

fuzz_target!(|data: &[u8]| {
    if data.len() > 0 {
        let allow = if (data[0] & 1) == 0 {
            AllowAnnotations::AnnotationsAllowed
        } else {
            AllowAnnotations::AnnotationsNotAllowed
        };
        if let Ok(s) = std::str::from_utf8(&data[1..]) {
            let _ = RouterReader::new(s, &allow).count();
        }
    }
});