Skip to content

Commit

Permalink
fix bound check in code chunking
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet committed Nov 26, 2021
1 parent 5ca9901 commit 6d40e11
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,13 @@ func touchEachChunks(start, end uint64, code []byte, contract *Contract, evm *EV
for chunk := start / 31; chunk <= end/31 && chunk <= uint64(len(code))/31; chunk++ {
index := trieUtils.GetTreeKeyCodeChunk(contract.Address().Bytes(), uint256.NewInt(chunk))
count := uint64(0)
end := (chunk + 1) * 31

// Look for the first code byte (i.e. no pushdata)
for ; count < 31 && !contract.IsCode(chunk*31+count); count++ {
for ; count < 31 && end+count < uint64(len(contract.Code)) && !contract.IsCode(chunk*31+count); count++ {
}
var value [32]byte
value[0] = byte(count)
end := (chunk + 1) * 31
if end > uint64(len(code)) {
end = uint64(len(code))
}
Expand Down

0 comments on commit 6d40e11

Please sign in to comment.