-
Notifications
You must be signed in to change notification settings - Fork 153
fdt: break loop compatibles when no NUL-terminator is found#807
Open
rizlik wants to merge 1 commit into
Open
Conversation
Contributor
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.
Pull request overview
This PR hardens the flattened device tree (FDT) compatible string-list parsing to avoid a potential hang when a compatible property is malformed (no NUL terminator within the declared property length), and adds a regression test to ensure the parser terminates.
Changes:
- Update
fdt_node_offset_by_compatible()to stop scanning thecompatibleproperty when no in-bounds NUL terminator is found. - Add a unit test with a minimal malformed FDT blob (unterminated
compatible) and run it in a dedicatedTCasewith a timeout to catch regressions as failures.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/unit-tests/unit-fdt.c | Adds a malformed-FDT regression test and a dedicated timeout test case to prevent suite hangs. |
| src/fdt.c | Breaks out of the compatible property scan when memchr() can’t find an in-bounds NUL terminator. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
738
to
+742
prop = nextprop + 1;
}
else {
/* No NUL terminator within the declared length, break. */
break;
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.
No description provided.