You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fn exec_returndatacopy(ref self: VM) -> Result<(), EVMError> {
let dest_offset = self.stack.pop_usize()?;
let offset = self.stack.pop_usize()?;
let size = self.stack.pop_usize()?;
let return_data: Span<u8> = self.return_data();
let (last_returndata_index, overflow) = offset.overflowing_add(size);
if overflow {
return Result::Err(EVMError::ReturnDataOutOfBounds);
}
ensure(!(last_returndata_index > return_data.len()), EVMError::ReturnDataOutOfBounds)?;
instead of doing size + offset to get the last returndata index, we check for overflows. Otherwise, we would get a CairoVM error that would fail the entire transaction
Ensure that no operation overflows.
example, in returndatacopy:
instead of doing size + offset to get the last returndata index, we check for overflows. Otherwise, we would get a CairoVM error that would fail the entire transaction
we can use something like
offset.overflowing_add(size).ok_or(EVMError::ReturnDataOutOfBounds)?;
to manage this efficiently
The text was updated successfully, but these errors were encountered: