Skip to content
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

test: Improve out-of-buffer detection in EOF tests #958

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

chfast
Copy link
Member

@chfast chfast commented Jul 24, 2024

In EOF validation tests, move the container to new heap-allocated buffer of exact size to easily find out-of-buffer reads with address sanitizer.

In EOF validation tests, move the container to new heap-allocated buffer
of exact size to easily find out-of-buffer reads with address sanitizer.
Copy link

codecov bot commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.30%. Comparing base (26d5609) to head (6a792b3).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #958   +/-   ##
=======================================
  Coverage   94.29%   94.30%           
=======================================
  Files         143      143           
  Lines       16138    16142    +4     
=======================================
+ Hits        15218    15222    +4     
  Misses        920      920           
Flag Coverage Δ
eof_execution_spec_tests 16.93% <0.00%> (-0.01%) ⬇️
ethereum_tests 26.90% <0.00%> (-0.01%) ⬇️
ethereum_tests_silkpre 18.68% <0.00%> (-0.01%) ⬇️
execution_spec_tests 17.90% <0.00%> (-0.01%) ⬇️
unittests 89.73% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
test/unittests/eof_validation.cpp 93.22% <100.00%> (+0.23%) ⬆️

@chfast chfast merged commit 6a792b3 into master Jul 24, 2024
22 of 28 checks passed
@chfast chfast deleted the tests/eof_outofbuffer_help branch July 24, 2024 10:46
Copy link
Collaborator

@pdobacz pdobacz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -110,9 +110,17 @@ void eof_validation::TearDown()
for (size_t i = 0; i < test_cases.size(); ++i)
{
const auto& test_case = test_cases[i];
EXPECT_EQ(evmone::validate_eof(rev, test_case.kind, test_case.container), test_case.error)

// Move the container to new heap-allocated buffer of exact size
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't test_case.container.shrink_to_fit() achieve the same?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for std::string where there is SSO and additional NULL terminator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants