From 212ed58c31fdf59b8a0a9f721d43e1f87329e7c8 Mon Sep 17 00:00:00 2001 From: LeanSerra <46695152+LeanSerra@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:49:54 -0300 Subject: [PATCH] fix(levm): correctly return outOfBounds in RETURNDATACOPY (#1515) **Motivation** Fix the remaining tests from the folder `stMemoryTest` **Description** - The opcode `RETURNDATACOPY` should fail if trying to read outside of the size of returndatabounds even if size is 0. Added a check for this case. **Resources** - Comment in line 238 and 238 from [this test](https://github.com/ethereum/tests/blob/develop/src/GeneralStateTestsFiller/stMemoryTest/bufferSrcOffsetFiller.yml#L238-L239) --- crates/vm/levm/src/opcode_handlers/environment.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vm/levm/src/opcode_handlers/environment.rs b/crates/vm/levm/src/opcode_handlers/environment.rs index 0896c2e962..4631784ccc 100644 --- a/crates/vm/levm/src/opcode_handlers/environment.rs +++ b/crates/vm/levm/src/opcode_handlers/environment.rs @@ -379,7 +379,7 @@ impl VM { gas_cost::returndatacopy(new_memory_size, current_call_frame.memory.len(), size)?, )?; - if size == 0 { + if size == 0 && returndata_offset == 0 { return Ok(OpcodeSuccess::Continue); }