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

30 lines
572 B
Rust
Raw Normal View History

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