Skip to content

Commit

Permalink
fix potential index out of range bugs in opDataHash (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-bayardo committed Sep 8, 2022
1 parent fce14ba commit e5291ef
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/vm/eips.go
Expand Up @@ -206,12 +206,12 @@ func enableSharding(jt *JumpTable) {

// opDataHash implements DATAHASH opcode
func opDataHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
idx := scope.Stack.pop()
if uint64(len(interpreter.evm.TxContext.DataHashes)) < idx.Uint64() {
scope.Stack.push(uint256.NewInt(0))
} else {
idx := scope.Stack.peek()
if idx.LtUint64(uint64(len(interpreter.evm.TxContext.DataHashes))) {
hash := interpreter.evm.TxContext.DataHashes[idx.Uint64()]
scope.Stack.push(new(uint256.Int).SetBytes(hash.Bytes()))
idx.SetBytes(hash.Bytes())
} else {
idx.Clear()
}
return nil, nil
}

0 comments on commit e5291ef

Please sign in to comment.