Skip to content

Commit

Permalink
Merge pull request ethereum#60 from shemnon/eof/extcodecopy-oob
Browse files Browse the repository at this point in the history
Limit EXTCODECOPY to eof bytes
  • Loading branch information
MariusVanDerWijden authored Feb 4, 2025
2 parents 56ff85a + 1156ca4 commit f0dc433
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
codeOffset = stack.pop()
length = stack.pop()
lengthU64 = length.Uint64()
codeCopy []byte
)
uint64CodeOffset, overflow := codeOffset.Uint64WithOverflow()
if overflow {
Expand All @@ -406,9 +407,10 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
witness.AddCode(code)
}
if isEOFVersion1(code) {
lengthU64 = 2
codeCopy = getData(eofMagic, uint64CodeOffset, lengthU64)
} else {
codeCopy = getData(code, uint64CodeOffset, lengthU64)
}
codeCopy := getData(code, uint64CodeOffset, lengthU64)
scope.Memory.Set(memOffset.Uint64(), lengthU64, codeCopy)

return nil, nil
Expand Down

0 comments on commit f0dc433

Please sign in to comment.