From 505a7ec9065e015d81414dfbf07ee4a69ece05da Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 21 Nov 2023 00:22:57 +0100 Subject: [PATCH] fix(evm): don't panic on short calldata --- crates/evm/evm/src/executors/fuzz/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index c92f0e21cfb4..3759962932a6 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -166,8 +166,11 @@ impl<'a> FuzzedExecutor<'a> { let reason = reason.to_string(); result.reason = if reason.is_empty() { None } else { Some(reason) }; - let args = - func.abi_decode_input(&calldata.as_ref()[4..], false).unwrap_or_default(); + let args = if let Some(data) = calldata.get(4..) { + func.abi_decode_input(data, false).unwrap_or_default() + } else { + vec![] + }; result.counterexample = Some(CounterExample::Single(BaseCounterExample { sender: None, addr: None,