* push

* fmt
This commit is contained in:
Dongjia "toka" Zhang 2023-07-05 13:03:09 +02:00 committed by GitHub
parent e5b3e5a677
commit 8cca87f2bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 21 deletions

View File

@ -1,7 +1,7 @@
# Variables # Variables
[env] [env]
FUZZER_NAME='fuzzer_libpng_launcher' FUZZER_NAME='fuzzer_libpng_launcher'
CARGO_TARGET_DIR = { value = "${PROJECT_DIR}/target/x86_64-unknown-linux-gnu", condition = { env_not_set = ["CARGO_TARGET_DIR"] } } CARGO_TARGET_DIR = { value = "${PROJECT_DIR}/target", condition = { env_not_set = ["CARGO_TARGET_DIR"] } }
LIBAFL_CC = '${CARGO_TARGET_DIR}/release/libafl_cc' LIBAFL_CC = '${CARGO_TARGET_DIR}/release/libafl_cc'
LIBAFL_CXX = '${CARGO_TARGET_DIR}/release/libafl_cxx' LIBAFL_CXX = '${CARGO_TARGET_DIR}/release/libafl_cxx'
LIBAFL_LIBTOOL = '${CARGO_TARGET_DIR}/release/libafl_libtool' LIBAFL_LIBTOOL = '${CARGO_TARGET_DIR}/release/libafl_libtool'
@ -35,9 +35,8 @@ mac_alias = "cxx_unix"
windows_alias = "unsupported" windows_alias = "unsupported"
[tasks.cxx_unix] [tasks.cxx_unix]
script="RUSTFLAGS=-Zsanitizer=address cargo +nightly build -Zbuild-std --target x86_64-unknown-linux-gnu --release" command = "cargo"
#command = "cargo" args = ["build" , "--release"]
#args = ["build" , "--release"]
[tasks.cc] [tasks.cc]
linux_alias = "cc_unix" linux_alias = "cc_unix"
@ -45,9 +44,8 @@ mac_alias = "cc_unix"
windows_alias = "unsupported" windows_alias = "unsupported"
[tasks.cc_unix] [tasks.cc_unix]
script="RUSTFLAGS=-Zsanitizer=address cargo +nightly build -Zbuild-std --target x86_64-unknown-linux-gnu --release" command = "cargo"
#command = "cargo" args = ["build" , "--release"]
#args = ["build" , "--release"]
# Library # Library
[tasks.lib] [tasks.lib]
@ -57,7 +55,7 @@ windows_alias = "unsupported"
[tasks.lib_unix] [tasks.lib_unix]
script_runner="@shell" script_runner="@shell"
cript=''' script='''
cd libpng-1.6.37 && ./configure --enable-shared=no --with-pic=yes --enable-hardware-optimizations=yes cd libpng-1.6.37 && ./configure --enable-shared=no --with-pic=yes --enable-hardware-optimizations=yes
cd "${PROJECT_DIR}" cd "${PROJECT_DIR}"
make -C libpng-1.6.37 CC="${CARGO_TARGET_DIR}/release/libafl_cc" CXX="${CARGO_TARGET_DIR}/release/libafl_cxx" LIBTOOL=${CARGO_TARGET_DIR}/release/libafl_libtool make -C libpng-1.6.37 CC="${CARGO_TARGET_DIR}/release/libafl_cc" CXX="${CARGO_TARGET_DIR}/release/libafl_cxx" LIBTOOL=${CARGO_TARGET_DIR}/release/libafl_libtool
@ -73,7 +71,7 @@ windows_alias = "unsupported"
[tasks.fuzzer_unix] [tasks.fuzzer_unix]
command = "${CARGO_TARGET_DIR}/release/libafl_cxx" command = "${CARGO_TARGET_DIR}/release/libafl_cxx"
args = ["${PROJECT_DIR}/harness.cc", "${PROJECT_DIR}/libpng-1.6.37/.libs/libpng16.a", "-I", "${PROJECT_DIR}/libpng-1.6.37/", "-o", "${FUZZER_NAME}", "-lm", "-lz", "-fsanitize=address"] args = ["${PROJECT_DIR}/harness.cc", "${PROJECT_DIR}/libpng-1.6.37/.libs/libpng16.a", "-I", "${PROJECT_DIR}/libpng-1.6.37/", "-o", "${FUZZER_NAME}", "-lm", "-lz"]
dependencies = [ "lib", "cxx", "cc" ] dependencies = [ "lib", "cxx", "cc" ]
# Run the fuzzer # Run the fuzzer

View File

@ -2,9 +2,9 @@
//! The example harness is built for libpng. //! The example harness is built for libpng.
//! In this example, you will see the use of the `launcher` feature. //! In this example, you will see the use of the `launcher` feature.
//! The `launcher` will spawn new processes for each cpu core. //! The `launcher` will spawn new processes for each cpu core.
//use mimalloc::MiMalloc; use mimalloc::MiMalloc;
//#[global_allocator] #[global_allocator]
//static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
use core::time::Duration; use core::time::Duration;
use std::{env, net::SocketAddr, path::PathBuf}; use std::{env, net::SocketAddr, path::PathBuf};
@ -197,15 +197,7 @@ pub fn libafl_main() {
let mut harness = |input: &BytesInput| { let mut harness = |input: &BytesInput| {
let target = input.target_bytes(); let target = input.target_bytes();
let buf = target.as_slice(); let buf = target.as_slice();
// Artificial timeout to check timeout
libfuzzer_test_one_input(buf); libfuzzer_test_one_input(buf);
// We're timeouting
if buf.len() == 42 {
println!("TIMEOUT :)");
std::thread::sleep(Duration::from_millis(1_000_000));
}
ExitKind::Ok ExitKind::Ok
}; };

View File

@ -298,7 +298,9 @@ where
corpus_idx: CorpusId, corpus_idx: CorpusId,
) -> Result<(), Error> { ) -> Result<(), Error> {
let mut testcase = state.corpus().get(corpus_idx)?.borrow_mut(); let mut testcase = state.corpus().get(corpus_idx)?.borrow_mut();
let Ok(input) = I::try_transform_from(&mut testcase, state, corpus_idx) else { return Ok(()); }; let Ok(input) = I::try_transform_from(&mut testcase, state, corpus_idx) else {
return Ok(());
};
drop(testcase); drop(testcase);
let mut generated = vec![]; let mut generated = vec![];