Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/evmone/eof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ std::variant<EOFSectionHeaders, EOFValidationError> validate_section_headers(byt
{
section_id = *it++;

// If DATA_SECTION is expected, CONTAINER_SECTION is also allowed, because
// container section is optional.
if (section_id != expected_section_id &&
(expected_section_id != DATA_SECTION || section_id != CONTAINER_SECTION))
// Skip optional sections.
if (section_id != expected_section_id && expected_section_id == CONTAINER_SECTION)
expected_section_id = DATA_SECTION;

if (section_id != expected_section_id)
return get_section_missing_error(expected_section_id);

switch (section_id)
Expand All @@ -128,7 +129,7 @@ std::variant<EOFSectionHeaders, EOFValidationError> validate_section_headers(byt
return EOFValidationError::zero_section_size;
if (section_num > CODE_SECTION_NUMBER_LIMIT)
return EOFValidationError::too_many_code_sections;
expected_section_id = DATA_SECTION;
expected_section_id = CONTAINER_SECTION;
state = State::section_size;
break;
}
Expand Down
6 changes: 6 additions & 0 deletions test/unittests/eof_validation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ TEST_F(eof_validation, minimal_valid_EOF1_multiple_code_sections)
EOFValidationError::success, "non_void_input_output");
}

TEST_F(eof_validation, minimal_valid_EOF1_multiple_container_sections)
{
add_test_case("EF0001 010004 0200010001 0300010001 0300010001 040000 00 00800000 00 00 00",
EOFValidationError::data_section_missing, "no_data_section");
}

TEST_F(eof_validation, EOF1_types_section_missing)
{
add_test_case("EF0001 0200010001 00 FE", EOFValidationError::type_section_missing);
Expand Down