Merge pull request #6 from AFLplusplus/vh_dcm

Vh dcm
This commit is contained in:
van Hauser 2020-12-20 16:33:25 +01:00 committed by GitHub
commit b26da86525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 30 deletions

View File

@ -3,7 +3,10 @@
use core::fmt::Debug; use core::fmt::Debug;
use core::marker::PhantomData; use core::marker::PhantomData;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{fs, path::Path}; use std::{
fs,
path::{Path, PathBuf},
};
use crate::corpus::{Corpus, Testcase}; use crate::corpus::{Corpus, Testcase};
use crate::events::EventManager; use crate::events::EventManager;
@ -101,7 +104,7 @@ where
generator: &mut G, generator: &mut G,
engine: &mut Engine<E, OT, ET, BytesInput>, engine: &mut Engine<E, OT, ET, BytesInput>,
manager: &mut EM, manager: &mut EM,
in_dir: Vec<String>, in_dirs: &[PathBuf],
) -> Result<(), AflError> ) -> Result<(), AflError>
where where
G: Generator<BytesInput, R>, G: Generator<BytesInput, R>,
@ -110,12 +113,12 @@ where
ET: ExecutorsTuple<BytesInput>, ET: ExecutorsTuple<BytesInput>,
EM: EventManager<C, E, OT, FT, BytesInput, R>, EM: EventManager<C, E, OT, FT, BytesInput, R>,
{ {
for directory in &in_dir { for in_dir in in_dirs {
self.load_from_directory(corpus, generator, engine, manager, Path::new(directory))?; self.load_from_directory(corpus, generator, engine, manager, in_dir)?;
} }
manager.log( manager.log(
0, 0,
format!("Loaded {} initial testcases", in_dir.len()), // get corpus count format!("Loaded {} initial testcases", in_dirs.len()), // get corpus count
)?; )?;
manager.process(self, corpus)?; manager.process(self, corpus)?;
Ok(()) Ok(())

View File

@ -6,6 +6,7 @@ extern crate alloc;
use clap::{App, Arg}; use clap::{App, Arg};
use std::env; use std::env;
use std::path::PathBuf;
use afl::corpus::Corpus; use afl::corpus::Corpus;
use afl::corpus::InMemoryCorpus; use afl::corpus::InMemoryCorpus;
@ -88,15 +89,15 @@ pub extern "C" fn afl_libfuzzer_main() {
env::current_dir().unwrap().to_string_lossy().to_string() env::current_dir().unwrap().to_string_lossy().to_string()
}; };
let mut dictionary: Option<Vec<String>> = None; let mut dictionary: Option<Vec<PathBuf>> = None;
if matches.is_present("dictionary") { if matches.is_present("dictionary") {
dictionary = Some(values_t!(matches, "dictionary", String).unwrap_or_else(|e| e.exit())); dictionary = Some(values_t!(matches, "dictionary", PathBuf).unwrap_or_else(|e| e.exit()));
} }
let mut input: Option<Vec<String>> = None; let mut input: Option<Vec<PathBuf>> = None;
if matches.is_present("workdir") { if matches.is_present("workdir") {
input = Some(values_t!(matches, "workdir", String).unwrap_or_else(|e| e.exit())); input = Some(values_t!(matches, "workdir", PathBuf).unwrap_or_else(|e| e.exit()));
} }
if dictionary != None || input != None { if dictionary != None || input != None {
@ -105,18 +106,13 @@ pub extern "C" fn afl_libfuzzer_main() {
// debug prints // debug prints
println!("workdir: {}", workdir); println!("workdir: {:?}", workdir);
if dictionary != None { match dictionary {
for file in dictionary.unwrap() { Some(x) => for file in x {
println!("dic: {}", file); println!("dic: {:?}", file);
} },
} None => (),
if input != None {
for indir in input.clone().unwrap() {
println!("in: {}", indir);
}
} }
// original code // original code
@ -151,16 +147,17 @@ pub extern "C" fn afl_libfuzzer_main() {
} }
} }
if input != None { match input {
state Some(x) => {
.load_initial_inputs( for indir in &x {
&mut corpus, println!("in: {:?}", indir);
&mut generator, };
&mut engine,
&mut mgr, state
input.unwrap(), .load_initial_inputs(&mut corpus, &mut generator, &mut engine, &mut mgr, &x)
) .expect("Failed to load initial corpus")
.expect("Failed to load initial corpus"); },
None => (),
} }
if corpus.count() < 1 { if corpus.count() < 1 {