From a7c4379976c7b60261224130f35e10724154a0b9 Mon Sep 17 00:00:00 2001 From: Erin Date: Fri, 3 Nov 2023 09:49:42 +0100 Subject: [PATCH] =?UTF-8?q?=C2=BBfixed=C2=AB=20fuzzer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hbvm/fuzz/fuzz_targets/vm.rs | 49 +++++++++++++++++------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/hbvm/fuzz/fuzz_targets/vm.rs b/hbvm/fuzz/fuzz_targets/vm.rs index 5cd2d2a..aa6d7cc 100644 --- a/hbvm/fuzz/fuzz_targets/vm.rs +++ b/hbvm/fuzz/fuzz_targets/vm.rs @@ -1,7 +1,6 @@ #![no_main] use { - hbbytecode::valider::validate, hbvm::{ mem::{ softpaging::{ @@ -16,35 +15,33 @@ use { }; fuzz_target!(|data: &[u8]| { - if validate(data).is_ok() { - let mut vm = unsafe { - Vm::<_, 16384>::new( - SoftPagedMem::<_, true> { - pf_handler: TestTrapHandler, - program: data, - root_pt: Box::into_raw(Default::default()), - icache: Default::default(), - }, - Address::new(4), - ) - }; + let mut vm = unsafe { + Vm::<_, 16384>::new( + SoftPagedMem::<_, true> { + pf_handler: TestTrapHandler, + program: data, + root_pt: Box::into_raw(Default::default()), + icache: Default::default(), + }, + Address::new(4), + ) + }; - // Alloc and map some memory - let pages = [ - alloc_and_map(&mut vm.memory, 0), - alloc_and_map(&mut vm.memory, 4096), - ]; + // Alloc and map some memory + let pages = [ + alloc_and_map(&mut vm.memory, 0), + alloc_and_map(&mut vm.memory, 4096), + ]; - // Run VM - let _ = vm.run(); + // Run VM + let _ = vm.run(); - // Unmap and dealloc the memory - for (i, page) in pages.into_iter().enumerate() { - unmap_and_dealloc(&mut vm.memory, page, i as u64 * 4096); - } - - let _ = unsafe { Box::from_raw(vm.memory.root_pt) }; + // Unmap and dealloc the memory + for (i, page) in pages.into_iter().enumerate() { + unmap_and_dealloc(&mut vm.memory, page, i as u64 * 4096); } + + let _ = unsafe { Box::from_raw(vm.memory.root_pt) }; }); fn alloc_and_map(memory: &mut SoftPagedMem, at: u64) -> *mut u8 {