mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
fuzz: explicitly keep or reject fuzzer corpus
When the main fuzzer function returns (), it is equivalent to returning Corpus::Keep. In some of the return paths, we want to reject the input so that the libfuzzer won't spend more time mutating them. The should make fuzzing more efficient. No functional change intended. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
@@ -5,14 +5,14 @@
|
||||
#![no_main]
|
||||
use devices::legacy::Cmos;
|
||||
use libc::EFD_NONBLOCK;
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||
use vm_device::BusDevice;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
fuzz_target!(|bytes| {
|
||||
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||
// Need at least 16 bytes for the test
|
||||
if bytes.len() < 16 {
|
||||
return;
|
||||
return Corpus::Reject;
|
||||
}
|
||||
|
||||
let mut below_4g = [0u8; 8];
|
||||
@@ -46,4 +46,6 @@ fuzz_target!(|bytes| {
|
||||
cmos.write(0, offset, &data);
|
||||
}
|
||||
}
|
||||
|
||||
Corpus::Keep
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user