-
Notifications
You must be signed in to change notification settings - Fork 285
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
Conversation
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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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.