Repository navigation
Conversation
`Fdt::new` walks the structure tokens up to `FDT_END` bounded only by the length of the blob, and never checks that `FDT_END` lies within `off_dt_struct + size_dt_struct`. `FdtMut` then takes `size_dt_struct` and `off_dt_strings` as the bounds of the structure block, so a blob whose `size_dt_struct` is shorter than the structure that was walked can make `shift_dt_struct`, `compact` and `add_property` panic, or write a property name over a structure token. Return `InvalidHeader` from `validate` when `FDT_END` ends past `off_dt_struct + size_dt_struct`. Together with the existing check that the strings block starts at or after the end of the structure block, this also refuses a strings block that begins inside the structure. Fixes google#110 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #112 +/- ##
==========================================
+ Coverage 93.61% 93.66% +0.05%
==========================================
Files 26 26
Lines 3428 3459 +31
==========================================
+ Hits 3209 3240 +31
Misses 219 219 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
validatenow returnsInvalidHeader, reported atsize_dt_struct, whenFDT_ENDends pastoff_dt_struct + size_dt_struct. With the existing check that the strings block starts at or after the end of the structure block, this also refuses a strings block that begins inside the structure.The tests cover the three inputs from the issue, an exactly sized structure block, and
FDT_NOPs or padding afterFDT_ENDinsidesize_dt_struct, which are still accepted. A test onFdtMut::from_slicecovers the mutable path.Fixes #110