Skip to content

Commit

Permalink
fix(EVM): Check the bytecode length on call (L-05) (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov authored Jan 3, 2025
1 parent 66c8e51 commit 969886c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion system-contracts/contracts/EvmEmulator.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2973,8 +2973,12 @@ object "EvmEmulator" {
getCodeAddress(),
BYTECODE_OFFSET(), // destination offset
0, // source offset
MAX_POSSIBLE_DEPLOYED_BYTECODE_LEN()
add(MAX_POSSIBLE_DEPLOYED_BYTECODE_LEN(), 1) // so we can check that bytecode isn't too big
)

if gt(codeLen, MAX_POSSIBLE_DEPLOYED_BYTECODE_LEN()) {
panic()
}

mstore(EMPTY_CODE_OFFSET(), 0)
mstore(BYTECODE_LEN_OFFSET(), codeLen)
Expand Down
6 changes: 5 additions & 1 deletion system-contracts/evm-emulator/EvmEmulator.template.yul
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ object "EvmEmulator" {
getCodeAddress(),
BYTECODE_OFFSET(), // destination offset
0, // source offset
MAX_POSSIBLE_DEPLOYED_BYTECODE_LEN()
add(MAX_POSSIBLE_DEPLOYED_BYTECODE_LEN(), 1) // so we can check that bytecode isn't too big
)

if gt(codeLen, MAX_POSSIBLE_DEPLOYED_BYTECODE_LEN()) {
panic()
}

mstore(EMPTY_CODE_OFFSET(), 0)
mstore(BYTECODE_LEN_OFFSET(), codeLen)
Expand Down

0 comments on commit 969886c

Please sign in to comment.