mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
core/vm: only allow eof calls from opExtCall
This commit is contained in:
parent
aa8e431183
commit
e1b9f4a6f5
1 changed files with 17 additions and 1 deletions
|
|
@ -1088,6 +1088,9 @@ func opExtCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]
|
||||||
// Pop other call parameters.
|
// Pop other call parameters.
|
||||||
addr, value, inOffset, inSize := stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
addr, value, inOffset, inSize := stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
||||||
toAddr := common.Address(addr.Bytes20())
|
toAddr := common.Address(addr.Bytes20())
|
||||||
|
if addr.ByteLen() > 20 {
|
||||||
|
return nil, errors.New("address space extension")
|
||||||
|
}
|
||||||
// safe a memory alloc
|
// safe a memory alloc
|
||||||
temp := addr
|
temp := addr
|
||||||
// Get the arguments from the memory.
|
// Get the arguments from the memory.
|
||||||
|
|
@ -1099,7 +1102,20 @@ func opExtCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]
|
||||||
if !value.IsZero() {
|
if !value.IsZero() {
|
||||||
gas += params.CallStipend
|
gas += params.CallStipend
|
||||||
}
|
}
|
||||||
ret, returnGas, err := interpreter.evm.Call(scope.Contract, toAddr, args, gas, &value)
|
// Check that we're only calling non-legacy contracts
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
ret []byte
|
||||||
|
returnGas uint64
|
||||||
|
)
|
||||||
|
code := interpreter.evm.StateDB.GetCode(toAddr)
|
||||||
|
if len(code) > 0 && !hasEOFMagic(code) {
|
||||||
|
err = errors.New("calling legacy contract from eof")
|
||||||
|
ret = nil
|
||||||
|
returnGas = gas
|
||||||
|
} else {
|
||||||
|
ret, returnGas, err = interpreter.evm.Call(scope.Contract, toAddr, args, gas, &value)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
temp.Clear()
|
temp.Clear()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue