From c8414cfca8e695524b7b05f638496a0e9e130992 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 27 Jun 2022 14:16:06 -0500 Subject: [PATCH] Fix guard size configuration when fuzzing (#4321) Fuzzers weren't updated to account for #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... --- crates/fuzzing/src/generators.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/fuzzing/src/generators.rs b/crates/fuzzing/src/generators.rs index 19c82b2654..d338fac377 100644 --- a/crates/fuzzing/src/generators.rs +++ b/crates/fuzzing/src/generators.rs @@ -249,12 +249,18 @@ impl<'a> Arbitrary<'a> for NormalMemoryConfig { fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result { // 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: as Arbitrary>::arbitrary(u)?.map(Into::into), static_memory_guard_size: as Arbitrary>::arbitrary(u)?.map(Into::into), dynamic_memory_guard_size: 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) } }