From f6b77f3dbbcb86f1e8ba3c4c9dc0fb0069c4bf4e Mon Sep 17 00:00:00 2001 From: Gianbelinche <39842759+gianbelinche@users.noreply.github.com> Date: Thu, 29 Aug 2024 14:16:20 -0300 Subject: [PATCH] Replace multiple overflow for 2 single overflows --- system-contracts/contracts/EvmInterpreterLoop.template.yul | 3 ++- system-contracts/contracts/EvmInterpreterPreprocessed.yul | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/system-contracts/contracts/EvmInterpreterLoop.template.yul b/system-contracts/contracts/EvmInterpreterLoop.template.yul index b2925c281..9fe08f42d 100644 --- a/system-contracts/contracts/EvmInterpreterLoop.template.yul +++ b/system-contracts/contracts/EvmInterpreterLoop.template.yul @@ -411,7 +411,8 @@ for { } true { } { size, sp := popStackItemWithoutCheck(sp) checkOverflow(destOffset, size, evmGasLeft) - checkMultipleOverflow(offset, size, MEM_OFFSET_INNER(), evmGasLeft) + checkOverflow(offset, size, evmGasLeft) + checkOverflow(add(offset, size), MEM_OFFSET_INNER(), evmGasLeft) checkMemOverflowByOffset(add(destOffset,size), evmGasLeft) if gt(add(add(offset, size), MEM_OFFSET_INNER()), MAX_MEMORY_FRAME()) { diff --git a/system-contracts/contracts/EvmInterpreterPreprocessed.yul b/system-contracts/contracts/EvmInterpreterPreprocessed.yul index 28794aadc..c1ce65a83 100644 --- a/system-contracts/contracts/EvmInterpreterPreprocessed.yul +++ b/system-contracts/contracts/EvmInterpreterPreprocessed.yul @@ -1942,7 +1942,8 @@ object "EVMInterpreter" { size, sp := popStackItemWithoutCheck(sp) checkOverflow(destOffset, size, evmGasLeft) - checkMultipleOverflow(offset, size, MEM_OFFSET_INNER(), evmGasLeft) + checkOverflow(offset, size, evmGasLeft) + checkOverflow(add(offset, size), MEM_OFFSET_INNER(), evmGasLeft) checkMemOverflowByOffset(add(destOffset,size), evmGasLeft) if gt(add(add(offset, size), MEM_OFFSET_INNER()), MAX_MEMORY_FRAME()) { @@ -4905,7 +4906,8 @@ object "EVMInterpreter" { size, sp := popStackItemWithoutCheck(sp) checkOverflow(destOffset, size, evmGasLeft) - checkMultipleOverflow(offset, size, MEM_OFFSET_INNER(), evmGasLeft) + checkOverflow(offset, size, evmGasLeft) + checkOverflow(add(offset, size), MEM_OFFSET_INNER(), evmGasLeft) checkMemOverflowByOffset(add(destOffset,size), evmGasLeft) if gt(add(add(offset, size), MEM_OFFSET_INNER()), MAX_MEMORY_FRAME()) {