Skip to content

Commit

Permalink
Move CALLF immediate argument validation to validate_instructions()
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Jun 6, 2023
1 parent 6e2a589 commit 93cc5fb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/evmone/eof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ EOFValidationError validate_instructions(
return EOFValidationError::invalid_rjumpv_count;
i += static_cast<size_t>(1 /* count */ + count * 2 /* tbl */);
}
else if (op == OP_CALLF)
{
const auto fid = read_uint16_be(&code[i + 1]);
if (fid >= header.types.size())
return EOFValidationError::invalid_code_section_index;
i += 2;
}
else if (op == OP_DATALOADN)
{
const auto index = read_uint16_be(&code[i + 1]);
Expand Down Expand Up @@ -329,9 +336,6 @@ std::variant<EOFValidationError, int32_t> validate_max_stack_height(
{
const auto fid = read_uint16_be(&code[i + 1]);

if (fid >= code_types.size())
return EOFValidationError::invalid_code_section_index;

stack_height_required = static_cast<int8_t>(code_types[fid].inputs);
stack_height_change =
static_cast<int8_t>(code_types[fid].outputs - stack_height_required);
Expand Down

0 comments on commit 93cc5fb

Please sign in to comment.