Code: Select all
#![no_main]
use libfuzzer_sys::fuzz_target;
use postcard::from_bytes;
use serde::{Deserialize, Serialize};
#[repr(C)]
#[derive(
Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize,
)]
struct ReadRequest {
pub fd: u64,
pub buf_addr: u64,
pub size: usize,
}
fuzz_target!(|data: &[u8]| {
match from_bytes::<ReadRequest>(data) {
Ok(mut req) => {
req.fd = 0;
req.buf_addr = 0;
req.size = 0;
}
Err(_) => {}
}
});