CALLF Stack validation height

CALLF should use the target function data when checking stack overflow.
This commit is contained in:
Danno Ferrin 2024-08-02 07:37:24 -06:00 committed by Marius van der Wijden
parent 71528b30a4
commit 28db438a8e

View file

@ -809,9 +809,9 @@ func opCallf(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by
var (
code = scope.Contract.CodeAt(scope.CodeSection)
idx = binary.BigEndian.Uint16(code[*pc+1:])
typ = scope.Contract.Container.Types[scope.CodeSection]
typ = scope.Contract.Container.Types[idx]
)
if scope.Stack.len()+int(typ.MaxStackHeight) >= 1024 {
if scope.Stack.len()+int(typ.MaxStackHeight)-int(typ.Input) > 1024 {
return nil, fmt.Errorf("stack overflow")
}
if len(scope.ReturnStack) > 1024 {