Skip to content

mutation testing: surviving mutants in EOF validation #1149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/evmone/eof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
break;
case CODE_SECTION:
{
if (it >= container_end - 1)
if (it > container_end - 1)

Check warning on line 121 in lib/evmone/eof.cpp

View check run for this annotation

Codecov / codecov/patch

lib/evmone/eof.cpp#L121

Added line #L121 was not covered by tests
return EOFValidationError::incomplete_section_number;
section_num = read_uint16_be(it);
it += 2;
Expand All @@ -136,7 +136,7 @@
break;
case CONTAINER_SECTION:
{
if (it >= container_end - 1)
if (it > container_end - 1)

Check warning on line 139 in lib/evmone/eof.cpp

View check run for this annotation

Codecov / codecov/patch

lib/evmone/eof.cpp#L139

Added line #L139 was not covered by tests
return EOFValidationError::incomplete_section_number;
section_num = read_uint16_be(it);
it += 2;
Expand All @@ -160,7 +160,7 @@
assert(section_num > 0); // Guaranteed by previous validation step.
for (size_t i = 0; i < section_num; ++i)
{
if (it >= container_end - 1)
if (it > container_end - 1)

Check warning on line 163 in lib/evmone/eof.cpp

View check run for this annotation

Codecov / codecov/patch

lib/evmone/eof.cpp#L163

Added line #L163 was not covered by tests
return EOFValidationError::incomplete_section_size;
const auto section_size = read_uint16_be(it);
it += 2;
Expand All @@ -172,7 +172,7 @@
}
else // TYPES_SECTION or DATA_SECTION
{
if (it >= container_end - 1)
if (it > container_end - 1)

Check warning on line 175 in lib/evmone/eof.cpp

View check run for this annotation

Codecov / codecov/patch

lib/evmone/eof.cpp#L175

Added line #L175 was not covered by tests
return EOFValidationError::incomplete_section_size;
const auto section_size = read_uint16_be(it);
it += 2;
Expand Down Expand Up @@ -210,7 +210,7 @@

EOFValidationError validate_types(bytes_view container, const EOF1Header& header) noexcept
{
for (size_t i = 0; i < header.get_type_count(); ++i)
for (size_t i = 0; i < header.get_type_count(); --i)

Check warning on line 213 in lib/evmone/eof.cpp

View check run for this annotation

Codecov / codecov/patch

lib/evmone/eof.cpp#L213

Added line #L213 was not covered by tests
{
const auto [inputs, outputs, max_stack_height] = header.get_type(container, i);

Expand Down Expand Up @@ -265,13 +265,13 @@
{
const auto count = code[i + 1] + 1;
i += static_cast<size_t>(1 /* max_index */ + count * 2 /* tbl */);
if (i >= code.size())
if (i > code.size())

Check warning on line 268 in lib/evmone/eof.cpp

View check run for this annotation

Codecov / codecov/patch

lib/evmone/eof.cpp#L268

Added line #L268 was not covered by tests
return EOFValidationError::truncated_instruction;
}
else if (op == OP_CALLF)
{
const auto fid = read_uint16_be(&code[i + 1]);
if (fid >= header.code_sizes.size())
if (fid > header.code_sizes.size())

Check warning on line 274 in lib/evmone/eof.cpp

View check run for this annotation

Codecov / codecov/patch

lib/evmone/eof.cpp#L274

Added line #L274 was not covered by tests
return EOFValidationError::invalid_code_section_index;

const auto type = header.get_type(container, fid);
Expand All @@ -289,7 +289,7 @@
else if (op == OP_JUMPF)
{
const auto fid = read_uint16_be(&code[i + 1]);
if (fid >= header.code_sizes.size())
if (fid > header.code_sizes.size())

Check warning on line 292 in lib/evmone/eof.cpp

View check run for this annotation

Codecov / codecov/patch

lib/evmone/eof.cpp#L292

Added line #L292 was not covered by tests
return EOFValidationError::invalid_code_section_index;

const auto type = header.get_type(container, fid);
Expand Down