* libafl-fuzz: fix id collision in Solution corpora

* libafl-fuzz: use dynamic map size

* print

* use PROJECT_DIR

* tmate

* idk

* AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

* a'

---------

Co-authored-by: aarnav <aarnav@srlabs.de>
This commit is contained in:
Dongjia "toka" Zhang 2024-09-25 15:45:48 +02:00 committed by GitHub
parent 4e54182b35
commit 3d1f0bfb0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 8 deletions

View File

@ -110,7 +110,7 @@ script = '''
# cmplog TODO: AFL_BENCH_UNTIL_CRASH=1 instead of timeout 15s # cmplog TODO: AFL_BENCH_UNTIL_CRASH=1 instead of timeout 15s
AFL_LLVM_CMPLOG=1 AFL_PATH=${AFL_DIR} ${AFL_CC_PATH} ./test/test-cmplog.c -o ./test/out-cmplog AFL_LLVM_CMPLOG=1 AFL_PATH=${AFL_DIR} ${AFL_CC_PATH} ./test/test-cmplog.c -o ./test/out-cmplog
AFL_CORES=1 timeout 5 ${FUZZER} -Z -l 3 -m 0 -V30 -i ./test/seeds_cmplog -o ./test/output-cmplog -c 0 ./test/out-cmplog || true AFL_CORES=1 timeout 5 ${FUZZER} -Z -l 3 -m 0 -V30 -i ./test/seeds_cmplog -o ./test/output-cmplog -c 0 ./test/out-cmplog || true
test -n "$( ls ./test/output-cmplog/fuzzer_main/crashes/id:0000* 2>/dev/null )" || { test -n "$( ls ${PROJECT_DIR}/test/output-cmplog/fuzzer_main/hangs/id:0000* ${PROJECT_DIR}/test/output-cmplog/fuzzer_main/crashes/id:0000*)" || {
echo "No crashes found" echo "No crashes found"
exit 1 exit 1
} }

View File

@ -6,9 +6,9 @@ use std::{
}; };
use libafl::{ use libafl::{
corpus::{Corpus, Testcase}, corpus::{Corpus, CorpusId, Testcase},
inputs::BytesInput, inputs::BytesInput,
state::{HasCorpus, HasExecutions, HasStartTime}, state::{HasCorpus, HasExecutions, HasSolutions, HasStartTime},
Error, Error,
}; };
use libafl_bolts::current_time; use libafl_bolts::current_time;
@ -19,9 +19,9 @@ use nix::{
use crate::{fuzzer::LibaflFuzzState, OUTPUT_GRACE}; use crate::{fuzzer::LibaflFuzzState, OUTPUT_GRACE};
pub fn generate_base_filename(state: &mut LibaflFuzzState) -> String { pub fn generate_base_filename(state: &mut LibaflFuzzState, id: CorpusId) -> String {
let id = id.0;
let is_seed = state.must_load_initial_inputs(); let is_seed = state.must_load_initial_inputs();
let id = state.corpus().peek_free_id().0;
let name = if is_seed { let name = if is_seed {
// TODO set orig filename // TODO set orig filename
format!("id:{id:0>6},time:0,execs:0,orig:TODO",) format!("id:{id:0>6},time:0,execs:0,orig:TODO",)
@ -46,7 +46,8 @@ pub fn set_corpus_filepath(
testcase: &mut Testcase<BytesInput>, testcase: &mut Testcase<BytesInput>,
_fuzzer_dir: &Path, _fuzzer_dir: &Path,
) -> Result<(), Error> { ) -> Result<(), Error> {
let mut name = generate_base_filename(state); let id = state.corpus().peek_free_id();
let mut name = generate_base_filename(state, id);
if testcase.hit_feedbacks().contains(&Cow::Borrowed("edges")) { if testcase.hit_feedbacks().contains(&Cow::Borrowed("edges")) {
name = format!("{name},+cov"); name = format!("{name},+cov");
} }
@ -64,7 +65,8 @@ pub fn set_solution_filepath(
) -> Result<(), Error> { ) -> Result<(), Error> {
// sig:0SIGNAL // sig:0SIGNAL
// TODO: verify if 0 time if objective found during seed loading // TODO: verify if 0 time if objective found during seed loading
let mut filename = generate_base_filename(state); let id = state.solutions().peek_free_id();
let mut filename = generate_base_filename(state, id);
let mut dir = "crashes"; let mut dir = "crashes";
if testcase if testcase
.hit_objectives() .hit_objectives()

View File

@ -252,7 +252,7 @@ where
// Finalize and build our Executor // Finalize and build our Executor
let mut executor = executor_builder let mut executor = executor_builder
.build(tuple_list!(time_observer, edges_observer)) .build_dynamic_map(edges_observer, tuple_list!(time_observer))
.unwrap(); .unwrap();
let queue_dir = fuzzer_dir.join("queue"); let queue_dir = fuzzer_dir.join("queue");