Skip to content

Commit

Permalink
Fix CALLDATACOPY non-compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
ilitteri committed Nov 25, 2024
1 parent 08f817d commit 43093d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/vm/levm/src/opcode_handlers/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl VM {
return Ok(OpcodeSuccess::Continue);
}

let mut data = [0u8; 32];
let mut data = vec![0u8; size];
for (i, byte) in current_call_frame
.calldata
.iter()
Expand Down
12 changes: 12 additions & 0 deletions crates/vm/levm/tests/edge_case_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,15 @@ fn test_is_negative() {
let mut current_call_frame = vm.call_frames.pop().unwrap();
vm.execute(&mut current_call_frame);
}

#[test]
fn test_non_compliance_calldatacopy_memory_resize() {
let mut vm =
new_vm_with_bytecode(Bytes::copy_from_slice(&[0x60, 34, 0x5f, 0x5f, 55, 89])).unwrap();
let mut current_call_frame = vm.call_frames.pop().unwrap();
vm.execute(&mut current_call_frame);
assert_eq!(
*current_call_frame.stack.stack.first().unwrap(),
U256::from(64)
);
}

0 comments on commit 43093d5

Please sign in to comment.