Skip to content

Commit

Permalink
Add Address Sanitizer exceptions to fuzzing targets, see image-rs#80
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnatsel committed Jun 27, 2018
1 parent 4da73cd commit 5c60ae1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions fuzz/fuzz_targets/fuzz_target_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
#[macro_use] extern crate libfuzzer_sys;
extern crate png;

// allocator_may_return_null=1 prevents crash on allocating huge amounts of memory, see #80
// detect_odr_violation=0 is for https://github.com/rust-lang/rust/issues/41807
const ASAN_DEFAULT_OPTIONS: &'static [u8] = b"allocator_may_return_null=1,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<u8>), ()> {
let decoder = png::Decoder::new(data);
Expand Down
4 changes: 3 additions & 1 deletion png-afl/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
extern crate afl;
extern crate png;

const ASAN_DEFAULT_OPTIONS: &'static [u8] = b"detect_odr_violation=1\0";
// allocator_may_return_null=1 prevents crash on allocating huge amounts of memory, see #80
// detect_odr_violation=0 is for https://github.com/rust-lang/rust/issues/41807
const ASAN_DEFAULT_OPTIONS: &'static [u8] = b"allocator_may_return_null=1,detect_odr_violation=0\0";

#[no_mangle]
pub extern "C" fn __asan_default_options() -> *const u8 {
Expand Down

0 comments on commit 5c60ae1

Please sign in to comment.