holey-bytes/hbvm/fuzz/fuzz_targets/vm.rs

30 lines
556 B
Rust
Raw Normal View History

2023-07-25 18:01:53 -05:00
#![no_main]
use {
hbvm::vm::{
mem::{HandlePageFault, Memory, MemoryAccessReason, PageSize},
Vm,
},
libfuzzer_sys::fuzz_target,
};
fuzz_target!(|data: &[u8]| {
if let Ok(mut vm) = Vm::<_, 0>::new_validated(data, TestTrapHandler) {
let _ = vm.run();
}
});
struct TestTrapHandler;
impl HandlePageFault for TestTrapHandler {
fn page_fault(
&mut self,
_: MemoryAccessReason,
_: &mut Memory,
_: u64,
_: PageSize,
_: *mut u8,
) -> bool {
false
}
}