1 // This file is Copyright its original authors, visible in version control
4 // This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
5 // or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
7 // You may not use this file except in accordance with one or both of these
10 #![cfg_attr(feature = "libfuzzer_fuzz", no_main)]
13 compile_error!("Fuzz targets need cfg=fuzzing");
15 extern crate dnssec_prover;
16 use dnssec_prover::ser::parse_rr_stream;
17 use dnssec_prover::validation::verify_rr_stream;
19 #[cfg(feature = "afl")]
20 #[macro_use] extern crate afl;
21 #[cfg(feature = "afl")]
24 let _ = parse_rr_stream(data).as_ref()
25 .map(|rrs| verify_rr_stream(rrs));
29 #[cfg(feature = "honggfuzz")]
30 #[macro_use] extern crate honggfuzz;
31 #[cfg(feature = "honggfuzz")]
35 let _ = parse_rr_stream(data).as_ref()
36 .map(|rrs| verify_rr_stream(rrs));
41 #[cfg(feature = "libfuzzer_fuzz")]
42 #[macro_use] extern crate libfuzzer_sys;
43 #[cfg(feature = "libfuzzer_fuzz")]
44 fuzz_target!(|data: &[u8]| {
45 let _ = parse_rr_stream(data).as_ref()
46 .map(|rrs| verify_rr_stream(rrs));
49 #[cfg(feature = "stdin_fuzz")]
53 let mut data = Vec::with_capacity(8192);
54 std::io::stdin().read_to_end(&mut data).unwrap();
55 let _ = parse_rr_stream(&data).as_ref()
56 .map(|rrs| verify_rr_stream(rrs));
64 if let Ok(tests) = fs::read_dir("test_cases/parse_response") {
66 let mut data: Vec<u8> = Vec::new();
67 let path = test.unwrap().path();
68 fs::File::open(&path).unwrap().read_to_end(&mut data).unwrap();
70 let _ = parse_rr_stream(&data).as_ref()
71 .map(|rrs| verify_rr_stream(rrs));