| 1 | #![no_main] |
| 2 | |
| 3 | use ec_inflate::{inflate, inflate_zlib}; |
| 4 | use libfuzzer_sys::fuzz_target; |
| 5 | |
| 6 | const LIMIT: usize = 16 << 20; |
| 7 | |
| 8 | |
| 9 | |
| 10 | fuzz_target!(|data: &[u8]| { |
| 11 | let Some((&sel, body)) = data.split_first() else { |
| 12 | return; |
| 13 | }; |
| 14 | let (ours, theirs) = if sel & 1 == 0 { |
| 15 | ( |
| 16 | inflate(body, LIMIT), |
| 17 | miniz_oxide::inflate::decompress_to_vec_with_limit(body, LIMIT), |
| 18 | ) |
| 19 | } else { |
| 20 | ( |
| 21 | inflate_zlib(body, LIMIT), |
| 22 | miniz_oxide::inflate::decompress_to_vec_zlib_with_limit(body, LIMIT), |
| 23 | ) |
| 24 | }; |
| 25 | if let (Ok(a), Ok(b)) = (ours, theirs) { |
| 26 | assert_eq!(a, b, "ec-inflate and miniz_oxide disagree"); |
| 27 | } |
| 28 | }); |