From 71db7e96c7de7c2ca658a0d22503c14cd00c9a80 Mon Sep 17 00:00:00 2001 From: whtsht Date: Tue, 5 Sep 2023 18:53:35 +0900 Subject: [PATCH 1/2] Remove code that sets detect_odr_violation=0 --- png-afl/src/main.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/png-afl/src/main.rs b/png-afl/src/main.rs index 2629cd0f..ac1e79e3 100644 --- a/png-afl/src/main.rs +++ b/png-afl/src/main.rs @@ -1,18 +1,9 @@ - #![forbid(unsafe_code)] #[macro_use] extern crate afl; extern crate png; -// detect_odr_violation=0 is for https://github.com/rust-lang/rust/issues/41807 -const ASAN_DEFAULT_OPTIONS: &'static [u8] = b"detect_odr_violation=0\0"; - -#[no_mangle] -pub extern "C" fn __asan_default_options() -> *const u8 { - ASAN_DEFAULT_OPTIONS as *const [u8] as *const u8 -} - #[inline(always)] fn png_decode(data: &[u8]) -> Result<(png::OutputInfo, Vec), ()> { let decoder = png::Decoder::new(data); From 6bcc80ab7b76306dc2bb989ab0b1a9ea0b38c996 Mon Sep 17 00:00:00 2001 From: whtsht Date: Tue, 5 Sep 2023 19:00:28 +0900 Subject: [PATCH 2/2] Fix mismatched types --- png-afl/src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/png-afl/src/main.rs b/png-afl/src/main.rs index ac1e79e3..6168d114 100644 --- a/png-afl/src/main.rs +++ b/png-afl/src/main.rs @@ -7,14 +7,16 @@ extern crate png; #[inline(always)] fn png_decode(data: &[u8]) -> Result<(png::OutputInfo, Vec), ()> { let decoder = png::Decoder::new(data); - let (info, mut reader) = decoder.read_info().map_err(|_| ())?; - if info.buffer_size() > 5_000_000 { + let mut reader = decoder.read_info().map_err(|_| ())?; + + let buffer_size = reader.output_buffer_size(); + if buffer_size > 5_000_000 { return Err(()); } - let mut img_data = vec![0u8; info.buffer_size()]; - reader.next_frame(&mut img_data).map_err(|_| ())?; + let mut img_data = vec![0u8; buffer_size]; + let info = reader.next_frame(&mut img_data).map_err(|_| ())?; Ok((info, img_data)) }