Skip to content

Commit

Permalink
core/vm: move fix for JUMPF
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden committed Sep 6, 2024
1 parent 7188fc5 commit df20601
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 2 additions & 4 deletions core/vm/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ 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)
if container.Types[arg].Output != 0x80 && container.Types[arg].Output > container.Types[section].Output {
return nil, fmt.Errorf("%w: arg %d, last %d, pos %d", ErrInvalidNumberOfOutputs, arg, len(container.Types), i)
}
visitedCode[arg] = struct{}{}
case op == DATALOADN:
Expand Down
3 changes: 0 additions & 3 deletions core/vm/validate_linear.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ func validateControlFlow2(code []byte, section int, metadata []*FunctionMetadata
return 0, fmt.Errorf("%w: at pos %d", ErrStackUnderflow{stackLen: have, required: want}, pos)
}
} else {
if metadata[section].Output < newSection.Output {
return 0, fmt.Errorf("%w: at pos %d", ErrInvalidNumberOfOutputs, pos)
}
if currentBounds.max != currentBounds.min {
return 0, fmt.Errorf("%w: max %d, min %d, at pos %d", ErrInvalidNumberOfOutputs, currentBounds.max, currentBounds.min, pos)
}
Expand Down

0 comments on commit df20601

Please sign in to comment.