Skip to content

Commit

Permalink
Fix guard size configuration when fuzzing (bytecodealliance#4321)
Browse files Browse the repository at this point in the history
Fuzzers weren't updated to account for bytecodealliance#4262 where guard sizes are now
validated rather than automatically sanitized. I'm not sure why oss-fuzz
hasn't filed a bug about this yet because it's definitely crashing a lot
on oss-fuzz...
  • Loading branch information
alexcrichton authored and afonso360 committed Jun 30, 2022
1 parent 1f46ca1 commit cb3bee3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/fuzzing/src/generators.rs
Expand Up @@ -249,12 +249,18 @@ impl<'a> Arbitrary<'a> for NormalMemoryConfig {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
// This attempts to limit memory and guard sizes to 32-bit ranges so
// we don't exhaust a 64-bit address space easily.
Ok(Self {
let mut ret = Self {
static_memory_maximum_size: <Option<u32> as Arbitrary>::arbitrary(u)?.map(Into::into),
static_memory_guard_size: <Option<u32> as Arbitrary>::arbitrary(u)?.map(Into::into),
dynamic_memory_guard_size: <Option<u32> as Arbitrary>::arbitrary(u)?.map(Into::into),
guard_before_linear_memory: u.arbitrary()?,
})
};

if let Some(dynamic) = ret.dynamic_memory_guard_size {
let statik = ret.static_memory_guard_size.unwrap_or(2 << 30);
ret.static_memory_guard_size = Some(statik.max(dynamic));
}
Ok(ret)
}
}

Expand Down

0 comments on commit cb3bee3

Please sign in to comment.