Skip to content

Commit e0b3585

Browse files
authored
core/vm: return copy of input slice in identity precompile. don't deep copy return data slice upon call completion (#13902)
Cherry pick ethereum/go-ethereum#25183. See erigontech/security#4
1 parent 956b40d commit e0b3585

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

core/vm/contracts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (c *dataCopy) RequiredGas(input []byte) uint64 {
299299
return uint64(len(input)+31)/32*params.IdentityPerWordGas + params.IdentityBaseGas
300300
}
301301
func (c *dataCopy) Run(in []byte) ([]byte, error) {
302-
return in, nil
302+
return libcommon.CopyBytes(in), nil
303303
}
304304

305305
// bigModExp implements a native big integer exponential modular operation.

core/vm/instructions.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt
768768
}
769769
stack.Push(&temp)
770770
if err == nil || err == ErrExecutionReverted {
771-
ret = libcommon.CopyBytes(ret)
772771
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
773772
}
774773

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

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

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

0 commit comments

Comments
 (0)