fix all errors

note: no fuzzing yet due to updates
This commit is contained in:
Graham Kelly 2024-03-29 17:16:49 -04:00
parent ffcf3708b6
commit 57659138a5

View file

@ -1,111 +1,111 @@
//! Fuzzing-specific utilities. //! Fuzzing-specific utilities.
use libfuzzer_sys::arbitrary; // use libfuzzer_sys::arbitrary;
pub fn reject(bytes: &[u8]) -> bool { // pub fn reject(bytes: &[u8]) -> bool {
let parser = wasmparser::Parser::new(0); // let parser = wasmparser::Parser::new(0);
let mut has_start = false; // let mut has_start = false;
let mut has_global_set = false; // let mut has_global_set = false;
let mut num_globals = 0; // let mut num_globals = 0;
for payload in parser.parse_all(bytes) { // for payload in parser.parse_all(bytes) {
match payload.unwrap() { // match payload.unwrap() {
wasmparser::Payload::CodeSectionEntry(body) => { // wasmparser::Payload::CodeSectionEntry(body) => {
for op in body.get_operators_reader().unwrap() { // for op in body.get_operators_reader().unwrap() {
let op = op.unwrap(); // let op = op.unwrap();
match op { // match op {
wasmparser::Operator::GlobalSet { .. } => { // wasmparser::Operator::GlobalSet { .. } => {
has_global_set = true; // has_global_set = true;
} // }
_ => {} // _ => {}
} // }
} // }
} // }
wasmparser::Payload::StartSection { .. } => { // wasmparser::Payload::StartSection { .. } => {
has_start = true; // has_start = true;
} // }
wasmparser::Payload::ExportSection(mut reader) => { // wasmparser::Payload::ExportSection(mut reader) => {
for _ in 0..reader.get_count() { // for _ in 0..reader.get_count() {
let e = reader.read().unwrap(); // let e = reader.read().unwrap();
match &e.kind { // match &e.kind {
&wasmparser::ExternalKind::Global => { // &wasmparser::ExternalKind::Global => {
num_globals += 1; // num_globals += 1;
} // }
_ => {} // _ => {}
} // }
} // }
} // }
wasmparser::Payload::MemorySection(mut reader) => { // wasmparser::Payload::MemorySection(mut reader) => {
for _ in 0..reader.get_count() { // for _ in 0..reader.get_count() {
let m = reader.read().unwrap(); // let m = reader.read().unwrap();
if m.maximum.is_none() || m.maximum.unwrap() > 100 { // if m.maximum.is_none() || m.maximum.unwrap() > 100 {
return true; // return true;
} // }
} // }
} // }
_ => {} // _ => {}
} // }
} // }
if !has_start || !has_global_set || num_globals < 1 { // if !has_start || !has_global_set || num_globals < 1 {
return true; // return true;
} // }
false // false
} // }
#[derive(Debug)] // #[derive(Debug)]
pub struct Config; // pub struct Config;
impl<'a> arbitrary::Arbitrary<'a> for Config { // impl<'a> arbitrary::Arbitrary<'a> for Config {
fn arbitrary(_u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> { // fn arbitrary(_u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
Ok(Config) // Ok(Config)
} // }
} // }
impl wasm_smith::Config for Config { // impl wasm_smith::Config for Config {
fn min_funcs(&self) -> usize { // fn min_funcs(&self) -> usize {
1 // 1
} // }
fn max_funcs(&self) -> usize { // fn max_funcs(&self) -> usize {
1 // 1
} // }
fn min_memories(&self) -> u32 { // fn min_memories(&self) -> u32 {
1 // 1
} // }
fn max_memories(&self) -> usize { // fn max_memories(&self) -> usize {
1 // 1
} // }
fn min_globals(&self) -> usize { // fn min_globals(&self) -> usize {
10 // 10
} // }
fn max_globals(&self) -> usize { // fn max_globals(&self) -> usize {
10 // 10
} // }
fn min_tables(&self) -> u32 { // fn min_tables(&self) -> u32 {
0 // 0
} // }
fn max_tables(&self) -> usize { // fn max_tables(&self) -> usize {
0 // 0
} // }
fn min_imports(&self) -> usize { // fn min_imports(&self) -> usize {
0 // 0
} // }
fn max_imports(&self) -> usize { // fn max_imports(&self) -> usize {
0 // 0
} // }
fn min_exports(&self) -> usize { // fn min_exports(&self) -> usize {
12 // 12
} // }
fn max_exports(&self) -> usize { // fn max_exports(&self) -> usize {
12 // 12
} // }
fn allow_start_export(&self) -> bool { // fn allow_start_export(&self) -> bool {
true // true
} // }
fn canonicalize_nans(&self) -> bool { // fn canonicalize_nans(&self) -> bool {
true // true
} // }
fn max_memory_pages(&self, _is_64: bool) -> u64 { // fn max_memory_pages(&self, _is_64: bool) -> u64 {
1 // 1
} // }
} // }