fix byte input reading
This commit is contained in:
parent
b73a971c51
commit
ffdaf22b1d
@ -1,5 +1,6 @@
|
||||
//! A singlethreaded QEMU fuzzer that can auto-restart.
|
||||
|
||||
use std::io::Read;
|
||||
use wcet_qemu_sys::system_trace::QemuSysStateObserver;
|
||||
use wcet_qemu_sys::worst::QemuHashMapObserver;
|
||||
use wcet_qemu_sys::{
|
||||
@ -140,7 +141,13 @@ pub fn main() {
|
||||
out_dir.push("queue");
|
||||
|
||||
let seed = match res.value_of("single") {
|
||||
Some(s) => Left(s.to_string()),
|
||||
Some(s) => if s=="-" {
|
||||
let mut buf = Vec::<u8>::new();
|
||||
std::io::stdin().read_to_end(&mut buf).expect("Could not read Stdin");
|
||||
Left(buf)
|
||||
} else {
|
||||
Left(s.as_bytes().to_owned())
|
||||
},
|
||||
None => {
|
||||
let in_dir = PathBuf::from(res.value_of("in").unwrap().to_string());
|
||||
if !in_dir.is_dir() {
|
||||
@ -150,6 +157,7 @@ pub fn main() {
|
||||
Right(in_dir)
|
||||
},
|
||||
};
|
||||
println!("{:?}",seed);
|
||||
|
||||
let kernel = PathBuf::from(res.value_of("k").unwrap().to_string());
|
||||
let edges = match res.value_of("edges") {
|
||||
@ -178,7 +186,7 @@ fn virt2phys(vaddr : u64, tab : &goblin::elf::Elf) -> u64 {
|
||||
|
||||
/// The actual fuzzer
|
||||
fn fuzz(
|
||||
seed: Either<String,PathBuf>,
|
||||
seed: Either<Vec<u8>,PathBuf>,
|
||||
kernel: PathBuf,
|
||||
dump_edges: Option<PathBuf>,
|
||||
snapshot: PathBuf,
|
||||
@ -316,7 +324,7 @@ fn fuzz(
|
||||
ExitKind::Ok
|
||||
};
|
||||
//======= Set System-State watchpoints
|
||||
let system_state_filter = QemuInstrumentationFilter::AllowList(vec![svh..svh+1]);
|
||||
let system_state_filter = QemuInstrumentationFilter::AllowList(vec![svh..svh+1,systick_handler..systick_handler+1,svc_handle..svc_handle+1]);
|
||||
|
||||
//======= Construct the executor, including the Helpers. The edges_observer still contains the ref to EDGES_MAP
|
||||
let mut executor = QemuExecutor::new(
|
||||
@ -351,7 +359,7 @@ fn fuzz(
|
||||
|
||||
},
|
||||
Left(s) => {
|
||||
fuzzer.evaluate_input(&mut state, &mut executor, &mut mgr, BytesInput::new(s.as_bytes().to_vec())).expect("Evaluation failed");
|
||||
fuzzer.evaluate_input(&mut state, &mut executor, &mut mgr, BytesInput::new(s)).expect("Evaluation failed");
|
||||
}
|
||||
}
|
||||
// let firstinput = match seed.clone().is_dir() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user