-
Notifications
You must be signed in to change notification settings - Fork 847
Prevent buffer overflow during log filter actions #6950
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
Merged
Merged
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
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When the buffer is not allocated (
m_client_req_unmapped_url_canon_str == INVALID_STR && m_client_req_unmapped_url_canon_len == 0), thisink_strlcpy()write\0to theINVALID_STR[0]?Uh oh!
There was an error while loading. Please reload this page.
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.
ln1164: m_client_req_unmapped_url_canon_str != 0
Uh oh!
There was an error while loading. Please reload this page.
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.
@masaori335 the problem is when sometimes
m_client_req_unmapped_url_canon_stris still pointing toINVALID_STR, but, the passed in sourcebufis the actual URL which is typically much longer thanINVALID_STR, (for whatever reason, haven't actually debugged whym_client_req_unmapped_url_canon_stris not correctly initialized), it'd end up overwriting the global space past theINVALID_STR.See for example
Uh oh!
There was an error while loading. Please reload this page.
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 agree with this change fix the buffer overflow.
What I'm wondering is this function will call
ink_strlcpylike below under the conditions.It might not be harmful, but meaningless.
The current checks in 1164 is only for nullptr. This doesn't work for
INVALID_STR, right?It looks better to check
m_client_req_unmapped_url_canon_strisINVALID_STRor not too.or
Uh oh!
There was an error while loading. Please reload this page.
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.
or just
if (buf && m_client_req_unmapped_url_canon_len > 0) {Note when it sets the str to
INVALID_STR, it does not set the length, intentionally.