[PR #7317] fix(firmware): accept empty strings at the reservation boundary #7815

Open
opened 2026-11-05 01:47:52 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/7317
Author: @ducanhnguyen223
Created: 10/26/2026
Status: 🔄 Open

Base: main ← Head: codex/fix-7315-empty-strings-dtb


📝 Commits (2)

  • 0095ae0 fix(firmware): accept empty FDT strings at reservation boundary
  • 6d26254 fix(firmware): treat empty DTB extents as non-overlapping

📊 Changes

4 files changed (+98 additions, -5 deletions)

View changed files

📝 src/firmware/devicetree/Devicetree.fixture.ts (+23 -0)
📝 src/firmware/devicetree/DevicetreeParser.test.ts (+37 -0)
📝 src/firmware/devicetree/DevicetreeParser.ts (+11 -5)
📝 tests/acceptance/devicetreeCli.test.ts (+27 -0)

📄 Description

Summary

Fixes #7315. Accept DTB v16 and v17 when a zero-length strings section lies anywhere within the blob, including inside the structure or reservation blocks.

Problem and expected behavior

When off_dt_strings equals off_mem_rsvmap and size_dt_strings is zero, the strings range contains no bytes. The parser nevertheless used its offset as the reservation-map limit and rejected the valid 16-byte terminator. Non-empty strings sections must remain boundaries, and actual section extents and overlaps must continue to be validated.

Change and scope

parseDevicetree excludes empty strings from reservation and v16 structure boundaries, and validates empty extents without treating them as overlapping. Offsets beyond totalsize and nonempty overlapping blocks remain invalid. A shared minimal fixture covers the parser and public CLI for both supported versions.

  • Semantic owner and earliest changed stage: parseDevicetree, section-boundary derivation before reservation-map scanning.
  • Contribution scope fit and linked maintainer decision: routine correction to existing read-only DTB inspection; separate scope decision is not applicable.
  • CLI/MCP/tool-catalog contract: no result-shape, schema, or catalog changes.
  • Format compatibility: FDT v16 and v17.
  • Evidence/provenance: input bytes and existing output evidence are preserved; only the false refusal is removed.
  • Target authority and side effects: reads the caller-selected local DTB; launches no target code and does not modify the input.
  • Generated metadata, package, or installation impact: none.
  • Expected effects: [x] Read existing files or captured data.

Evidence and regression coverage

  • Tests: 37 parser tests, 8 compiled CLI acceptance tests, and 4 MCP boundary tests passed. The v16 and v17 cases at structure offset 44 failed before the follow-up, with an unterminated name and an overlap error respectively; offsets in the header, structure, reservation, and at EOF now pass. Offsets beyond totalsize remain rejected.
  • Base reproduction: the new parser regression failed on the pre-fix code for v16 and v17 with Unterminated or overlapping FDT reservation block.
  • CLI result: both versioned fixtures now exit 0 and report the root node and no reservation entries.
  • Remaining proof gaps: fixtures are minimal synthetic DTBs; hardware-produced samples and hardware/provider workflows were not tested.

Validation performed

Follow-up validation ran on macOS arm64 with Node 24.22.1 and the branch lockfile. The Devicetree specification permits the strings block at any offset.

  • npm run test:focused -- src/firmware/devicetree/DevicetreeParser.test.ts tests/acceptance/devicetreeCli.test.ts tests/boundary/mcp/devicetreeMcp.test.ts — 49/49 passed.
  • npm run check:fast — 2/2 tasks successful.
  • npm exec -- oxfmt --check src/firmware/devicetree/DevicetreeParser.ts src/firmware/devicetree/DevicetreeParser.test.ts src/firmware/devicetree/Devicetree.fixture.ts tests/acceptance/devicetreeCli.test.ts — passed.
  • git diff --check — passed.

Compatibility, safety, and release

  • Breaking change or migration: none.
  • Real hardware/provider coverage: not run; the change is confined to local DTB parsing.
  • Package or release metadata impact: none.

Author readiness

Human owner: @ducanhnguyen223

  • I reviewed the final diff and take responsibility for the complete PR.
  • I checked the evidence and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem.
  • Scope and authority questions are resolved.
  • The PR has one focused outcome.
  • Related issue is linked.
  • Tests cover changed behavior.
  • Owning docs, contracts, or generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets and unrelated changes.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/7317 **Author:** [@ducanhnguyen223](https://github.com/ducanhnguyen223) **Created:** 10/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/fix-7315-empty-strings-dtb` --- ### 📝 Commits (2) - [`0095ae0`](https://github.com/morluto/rea/commit/0095ae0894bb7e8550ff0e57959a17f8d7610531) fix(firmware): accept empty FDT strings at reservation boundary - [`6d26254`](https://github.com/morluto/rea/commit/6d262541bc8422319a87d7a9a85b8aee02259e12) fix(firmware): treat empty DTB extents as non-overlapping ### 📊 Changes **4 files changed** (+98 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/firmware/devicetree/Devicetree.fixture.ts` (+23 -0) 📝 `src/firmware/devicetree/DevicetreeParser.test.ts` (+37 -0) 📝 `src/firmware/devicetree/DevicetreeParser.ts` (+11 -5) 📝 `tests/acceptance/devicetreeCli.test.ts` (+27 -0) </details> ### 📄 Description ## Summary Fixes #7315. Accept DTB v16 and v17 when a zero-length strings section lies anywhere within the blob, including inside the structure or reservation blocks. ## Problem and expected behavior When `off_dt_strings` equals `off_mem_rsvmap` and `size_dt_strings` is zero, the strings range contains no bytes. The parser nevertheless used its offset as the reservation-map limit and rejected the valid 16-byte terminator. Non-empty strings sections must remain boundaries, and actual section extents and overlaps must continue to be validated. ## Change and scope `parseDevicetree` excludes empty strings from reservation and v16 structure boundaries, and validates empty extents without treating them as overlapping. Offsets beyond totalsize and nonempty overlapping blocks remain invalid. A shared minimal fixture covers the parser and public CLI for both supported versions. - Semantic owner and earliest changed stage: `parseDevicetree`, section-boundary derivation before reservation-map scanning. - Contribution scope fit and linked maintainer decision: routine correction to existing read-only DTB inspection; separate scope decision is not applicable. - CLI/MCP/tool-catalog contract: no result-shape, schema, or catalog changes. - Format compatibility: FDT v16 and v17. - Evidence/provenance: input bytes and existing output evidence are preserved; only the false refusal is removed. - Target authority and side effects: reads the caller-selected local DTB; launches no target code and does not modify the input. - Generated metadata, package, or installation impact: none. - Expected effects: [x] Read existing files or captured data. ## Evidence and regression coverage - Tests: 37 parser tests, 8 compiled CLI acceptance tests, and 4 MCP boundary tests passed. The v16 and v17 cases at structure offset 44 failed before the follow-up, with an unterminated name and an overlap error respectively; offsets in the header, structure, reservation, and at EOF now pass. Offsets beyond totalsize remain rejected. - Base reproduction: the new parser regression failed on the pre-fix code for v16 and v17 with `Unterminated or overlapping FDT reservation block`. - CLI result: both versioned fixtures now exit 0 and report the root node and no reservation entries. - Remaining proof gaps: fixtures are minimal synthetic DTBs; hardware-produced samples and hardware/provider workflows were not tested. ## Validation performed Follow-up validation ran on macOS arm64 with Node 24.22.1 and the branch lockfile. The [Devicetree specification](https://devicetree-specification.readthedocs.io/en/stable/flattened-format.html#strings-block) permits the strings block at any offset. - `npm run test:focused -- src/firmware/devicetree/DevicetreeParser.test.ts tests/acceptance/devicetreeCli.test.ts tests/boundary/mcp/devicetreeMcp.test.ts` — 49/49 passed. - `npm run check:fast` — 2/2 tasks successful. - `npm exec -- oxfmt --check src/firmware/devicetree/DevicetreeParser.ts src/firmware/devicetree/DevicetreeParser.test.ts src/firmware/devicetree/Devicetree.fixture.ts tests/acceptance/devicetreeCli.test.ts` — passed. - `git diff --check` — passed. ## Compatibility, safety, and release - Breaking change or migration: none. - Real hardware/provider coverage: not run; the change is confined to local DTB parsing. - Package or release metadata impact: none. ## Author readiness Human owner: @ducanhnguyen223 - [ ] I reviewed the final diff and take responsibility for the complete PR. - [ ] I checked the evidence and recorded meaningful validation gaps. - [ ] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem. - [ ] Scope and authority questions are resolved. - [ ] The PR has one focused outcome. - [ ] Related issue is linked. - [ ] Tests cover changed behavior. - [ ] Owning docs, contracts, or generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets and unrelated changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7815
No description provided.