-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix attribute reads into a large buffer to not read random memory. #4382
Merged
andy31415
merged 1 commit into
project-chip:master
from
bzbarsky-apple:fix-type-sensitive-copy
Jan 15, 2021
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 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.
why is the caller buffer size ignored when write is set? I would expect at least a min(readLength, am-size) and I think we should log on mismatch to catch logic errors.
Generally I have complains about this method to start with: a buffer length that seems to be only relevant on read (called readLength) but method used on both read and write and a direction parameter when the caller could just have flipped src and destination.
I generally would apply the test 'Can one clearly in one sentence describe what a method does, generally without 'IF' or conditionals?'. I think this method fails hard because it has a 'write' parameter that affects behaviour as well as special conditions for readLength.
Could we fix up this method and make it somehow easier to use?
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.
Apart from that being the documented behavior of
emAfReadOrWriteAttribute
and all callers who setwrite
passing 0 for the size? I'm afraid I don't know why the setup is the way it is; that's a question for @selissia or @tecimovic.Yes, we could, and I agree we should. We'd need to audit all consumers to see what they are doing with
readLength
; the comments suggest that there are legacy consumers that pass 0 for reads as well....I'm happy to do that, but it might be a few days before I can pull enough time off of spec stuff to do it. I'm happy to land this in the meantime to unblock your ASan changes and do the larger semantic-changing refactoring in a followup, or expand the scope of this PR, as long as you're OK with the corresponding lag. Please let me know.
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.
created #4394 to track improvement in buffer handling within this code.
Is this generated code? if so, how would one go about on changing the code and updating?
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.
Just to close the loop on this: this is not generated code.