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
time-util: fix buffer-over-run #23933
Conversation
@@ -238,6 +238,11 @@ TEST(format_timespan) { | |||
test_format_timespan_accuracy(1); | |||
test_format_timespan_accuracy(USEC_PER_MSEC); | |||
test_format_timespan_accuracy(USEC_PER_SEC); | |||
|
|||
/* See issue #23928. */ | |||
_cleanup_free_ char *buf; |
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.
Why not just char buf[5]
?
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.
I do not know why, but valgrind does not detect the buffer-over-run if buf[5]
is used.
ASAN may detect the issue even with buf[5]
. But this is just a test code, hence I hope that's no problem.
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.
I do not know why, but valgrind does not detect the buffer-over-run if
buf[5]
is used.
Because valgrind's memcheck
doesn't check stack allocations.
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.
Ah, thanks.
Fixes #23928.