mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
core/vm: no more recursive errors
This commit is contained in:
parent
cdae48c452
commit
5a1acc4a07
2 changed files with 11 additions and 2 deletions
|
|
@ -89,7 +89,7 @@ type Container struct {
|
|||
ContainerSections []*Container
|
||||
ContainerCode [][]byte
|
||||
Data []byte
|
||||
DataSize int // might be less than len(Data)
|
||||
DataSize int // might be more than len(Data)
|
||||
}
|
||||
|
||||
// FunctionMetadata is an EOF function signature.
|
||||
|
|
@ -292,7 +292,10 @@ func (c *Container) unmarshalSubContainer(b []byte, isInitcode bool, topLevel bo
|
|||
c := new(Container)
|
||||
end := min(idx+size, len(b))
|
||||
if err := c.unmarshalSubContainer(b[idx:end], isInitcode, false); err != nil {
|
||||
return fmt.Errorf("%w for section %d", err, i)
|
||||
if topLevel {
|
||||
return fmt.Errorf("%w in sub container %d", err, i)
|
||||
}
|
||||
return err
|
||||
}
|
||||
container = append(container, c)
|
||||
containerCode = append(containerCode, b[idx:end])
|
||||
|
|
|
|||
|
|
@ -120,9 +120,15 @@ func validateCode(code []byte, section int, container *Container, jt *JumpTable,
|
|||
if arg >= len(container.Types) {
|
||||
return nil, fmt.Errorf("%w: arg %d, last %d, pos %d", ErrInvalidSectionArgument, arg, len(container.Types), i)
|
||||
}
|
||||
// TODO check if that is actually a problem
|
||||
// JUMPF operand must point to a code section with equal or fewer number of outputs as the section in which it resides, or to a section with 0x80 as outputs (non-returning)
|
||||
if container.Types[arg].Output > container.Types[section].Output {
|
||||
return nil, fmt.Errorf("%w: arg %d, last %d, pos %d", ErrInvalidSectionArgument, arg, len(container.Types), i)
|
||||
}
|
||||
visitedCode[arg] = struct{}{}
|
||||
case op == DATALOADN:
|
||||
arg, _ := parseUint16(code[i+1:])
|
||||
// TODO why are we checking this? We should just pad
|
||||
if arg+32 > len(container.Data) {
|
||||
return nil, fmt.Errorf("%w: arg %d, last %d, pos %d", ErrInvalidDataloadNArgument, arg, len(container.Data), i)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue