Repository navigation
fix(apple): preserve post-table plist objects - #7820
Merged
Merged
Conversation
Contributor
[Medium impact] The reviewed changes appear safe to merge. SummaryThe private binary plist decoder copy now preserves bytes before the trailer and appends replacement records and a fresh offset table.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Original bytes] --> B[Check required space]
B --> C[Copy bytes before trailer unchanged]
C --> D[Append replacement records]
D --> E[Write fresh offset table]
E --> F[Write updated trailer]
F --> G[Decode using fresh offsets]
Reviews (1) · Last reviewed commit: "fix(apple): preserve post-table plist ob..." · Reviewed by Greptile |
morluto
marked this pull request as ready for review
October 28, 2026 15:40
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 of 11 tasks
devreddy1015
added a commit
to devreddy1015/rea
that referenced
this pull request
Oct 29, 2026
Review follow-up (Codex). Decoder bounds admit an offset table that runs into the trailer and an object stored in the trailer's spare bytes after it. With dates now observed for that layout, an overlapping sub-millisecond date reaches cloneBinaryPlistObjects. Since morluto#7820 the rewrite appends clones and a fresh table, but only after the bytes before the trailer, so it overwrote such an object and plist@5 failed with "Unsupported int size: 256". Copy the whole source buffer and append the clones, the new table and a new trailer after it. The old table and trailer stay as inert bytes, so every source offset still names its original record. The offset width and both preflight estimates now account for the clones starting at the end of the buffer and for the extra trailer.
2 tasks done
morluto
added a commit
that referenced
this pull request
Nov 26, 2026
… the trailer (#7166) * fix(apple): observe keyed-archive dates when the offset table reaches the trailer inspect_keyed_archive preflights binary plists with decoder bounds, which admit an offset table that ends anywhere before end of file, including inside the 32-byte trailer. plist@5 reads such a table. Dates must still end before the offset table, so the preflight records each reachable date. The scalar scanner, however, required the table to end before the trailer. For a table that runs into the trailer it abandoned the whole file and collected no dates. The precision clamp in decodeBinaryPlistScalars then saw no unrepresentable date, so a 0.1005 s instant was reported as the exact timestamp 2001-01-01T00:00:00.100Z with no unknown-date limitation. Bound the scanner's offset-table reads by the end of the file, which is the widest table any preflight admits. Strict preflight already rejects tables past the trailer before scanning, so strict callers are unchanged. Object and date bounds still end at the offset table. * fix(apple): rebuild a complete trailer when cloning plist scalars Review follow-up. With the scanner observing dates when the offset table runs into the trailer, a sub-millisecond date that overlaps another object now reaches cloneBinaryPlistObjects. That rewrite sized its output as bytes.length plus the growth of a table assumed to end before the trailer. When the old table overlaps the trailer, those bytes exist only once, so the buffer came out short and the copied trailer was truncated. plist@5 then failed with "Unsupported int size: 0". binaryPlistCloneGrowth now computes the bytes a clone rewrite adds, subtracting only the old table bytes that precede the trailer. The allocator and both preflight budget estimates use it, so admission and allocation agree. For tables that end before the trailer the value is unchanged. * fix(apple): keep every source byte when cloning plist scalars Review follow-up (Codex). Decoder bounds admit an offset table that runs into the trailer and an object stored in the trailer's spare bytes after it. With dates now observed for that layout, an overlapping sub-millisecond date reaches cloneBinaryPlistObjects. Since #7820 the rewrite appends clones and a fresh table, but only after the bytes before the trailer, so it overwrote such an object and plist@5 failed with "Unsupported int size: 256". Copy the whole source buffer and append the clones, the new table and a new trailer after it. The old table and trailer stay as inert bytes, so every source offset still names its original record. The offset width and both preflight estimates now account for the clones starting at the end of the buffer and for the extra trailer. * test(apple): match main's limitation assertions in keyed-archive date tests * fix(apple): observe binary plist dates only when they end before the trailer --------- Co-authored-by: morluto <[email protected]>
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.
Summary
Fixes #7348. A binary keyed archive whose object data follows its offset table can report the original string as an observed null when REA normalizes an unusual offset width. The decoder copy now retains the original object offsets and returns the string.
Problem and expected behavior
An admitted three-byte table followed by a
helloobject moved that object while keeping its old offset. The private decoder copy must preserve the selected artifact's values and the original bytes.Change and scope
Append replacement records and a fresh offset table after the original bytes before the trailer. Calculate the required width and charge the added representation before allocation. Clone-layout tests read offsets from the produced table instead of assuming where a clone is placed.
PR #7166 addresses a separate table/trailer overlap and touches the same owner; its description explicitly excludes this post-table relocation. The two changes need reconciliation if both are merged.
Contract and boundary impact
Expected effects:
Evidence and regression coverage
hellofor all controls.status: observed,value: hello.Boundary coverage includes unusual offset widths, before/after-table layouts, unchanged source bytes and the existing capacity checks. No lifecycle change is involved.
Validation performed
npm run test:focused -- tests/acceptance/applications/keyedArchivePostTable.test.ts— passed; CLI checks three post-table widths and a pre-table control, including unchanged input bytes.npm run test:local -- src/artifacts/apple/PlistScalars.test.ts src/artifacts/apple/KeyedArchiveReader.test.ts src/artifacts/apple/InterfaceBuilderDecodeBudget.test.ts— 80 passed.npm run check:fastandgit diff --check— passed.Compatibility, safety, and release
No intended breaking change, new authority or package impact. Native Foundation behavior and real-exporter frequency were not verified; the fixture is synthetic. MCP was not exercised independently.
Author readiness
Human owner: @morluto
Before merge
type(scope): outcome.