Skip to content

Commit

Permalink
core/vm: return copy of input slice in identity precompile. don't dee…
Browse files Browse the repository at this point in the history
…p copy return data slice upon call completion (#13902)

Cherry pick ethereum/go-ethereum#25183. See
erigontech/security#4
  • Loading branch information
yperbasis authored Feb 21, 2025
1 parent 956b40d commit e0b3585
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (c *dataCopy) RequiredGas(input []byte) uint64 {
return uint64(len(input)+31)/32*params.IdentityPerWordGas + params.IdentityBaseGas
}
func (c *dataCopy) Run(in []byte) ([]byte, error) {
return in, nil
return libcommon.CopyBytes(in), nil
}

// bigModExp implements a native big integer exponential modular operation.
Expand Down
4 changes: 0 additions & 4 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt
}
stack.Push(&temp)
if err == nil || err == ErrExecutionReverted {
ret = libcommon.CopyBytes(ret)
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
}

Expand Down Expand Up @@ -802,7 +801,6 @@ func opCallCode(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([
}
stack.Push(&temp)
if err == nil || err == ErrExecutionReverted {
ret = libcommon.CopyBytes(ret)
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
}

Expand Down Expand Up @@ -832,7 +830,6 @@ func opDelegateCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
}
stack.Push(&temp)
if err == nil || err == ErrExecutionReverted {
ret = libcommon.CopyBytes(ret)
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
}

Expand Down Expand Up @@ -862,7 +859,6 @@ func opStaticCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
}
stack.Push(&temp)
if err == nil || err == ErrExecutionReverted {
ret = libcommon.CopyBytes(ret)
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
}

Expand Down

0 comments on commit e0b3585

Please sign in to comment.