-
Notifications
You must be signed in to change notification settings - Fork 896
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
[CodeHealth] Use span of bytes to read arbitrary data #25978
Conversation
117139a
to
920b1de
Compare
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.
LGTM
920b1de
to
f5e5dca
Compare
Dismissing review as adding tests as discussed. Thanks
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.
macOS LGTM++
f5e5dca
to
d98e457
Compare
[puLL-Merge] - brave/brave-core@25978 DescriptionThis PR introduces several changes to improve code quality, security, and add unit tests for the device ID implementation in the Brave browser. The main focus is on refactoring the MAC address validation logic and improving the handling of byte operations. ChangesChanges
Possible Issues
Security Hotspots
|
d98e457
to
a7dfc93
Compare
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.
LGTM
a7dfc93
to
d03f56b
Compare
This PR touches in different places of the code base where the use of `reinterpret_cast` was necessary to allow data to be handled in different format. Span is both safer and more ergonimic. It is preferrable over `void*`, and particularly we should avoid any type of casts involving byte values to numeric values, as those can cause undefined behaviour. This change additionally refactors `DeviceIdImpl::IsValidMacAddress` to use `base::MakeFixedFlatSet` for the set of invalid mac addresses we were searching for, as the search was sequential, and for successful values it meant visiting every element in the array to check for comparison. To make sure the binary search works as expected, a test has been added.
d03f56b
to
d0160c0
Compare
Released in v1.73.21 |
This PR touches in different places of the code base where the use of
reinterpret_cast
was necessary to allow data to be handled in different format. Span is both safer and more ergonimic. It is preferrable overvoid*
, and particularly we should avoid any type of casts involving byte values to numeric values, as those can cause undefined behaviour.This change additionally refactors
DeviceIdImpl::IsValidMacAddress
to usebase::MakeFixedFlatSet
for the set of invalid mac addresses we were searching for, as the search was sequential, and for successful values it meant visiting every element in the array to check for comparison.Resolves
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: