Repository navigation
fix(apple): observe keyed-archive dates when the offset table reaches the trailer - #7166
Conversation
… 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.
[Medium impact] The PR appears safe to merge; no new blocking issue was found. SummaryThe PR preserves date uncertainty when a binary plist’s offset table reaches the trailer.
No new actionable issues were found. The merged #7820 fix is already in the base; this PR adds distinct fixes beyond it. GitHub discussion checks were blocked by missing authentication. Tests were not run during this review. Reviews (6) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
Codex Review Summary: ❌ FailedThis 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. |
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.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e88c07c511
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…e-table-bounds # Conflicts: # src/artifacts/apple/PlistScalars.ts # src/artifacts/apple/PropertyListDecodeBudget.ts
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.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Hey @devreddy1015, thanks for this! The fix looks good. What's left: there is 1 unresolved review thread from Codex, about "Preserve post-table objects when date scanning triggers cloning". Happy to get this in once that's sorted out. |
|
TL;DR: On head fa44319, all 38 tests in Edit (11 Nov): I ran the new head, 992ece7, in a VM, and the results are here.
For the red run, I put In the Node 24.22.1 red log, these 3 tests fail:
So these 3 tests fail without the fix and pass with it. CI on fa44319:
The head is 502 commits behind main b81da90. GitHub says the PR is mergeable, and its merge state is blocked. Not run
Test setup
Commandsnpm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/artifacts/apple/KeyedArchiveReader.test.ts🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e071f6985f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
TL;DR: I ran the PR's changed test file on head 992ece7 under three Node versions. All 40 tests passed each time. The
The PR changes 3 files against the merge base cb4e5cf. Those are the test file, CI on 992ece7, read live with
The head is 405 commits behind main dcdae13. Not run
Test setupCommandsnpm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/artifacts/apple/KeyedArchiveReader.test.ts🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊 |
…e-table-bounds # Conflicts: # src/artifacts/apple/KeyedArchiveReader.test.ts
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…e-table-bounds plist 5.1.1 rejects an offset table that runs into the trailer, so the tests no longer call parseBinary on those fixtures; rea decodes a rebuilt copy with a fresh trailer. Match main's "not a keyed archive" error.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@morluto I merged the latest main (no conflicts) and Greptile's re-review is 5/5. Could you approve the workflows when you have a moment? Thanks! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
inspect_keyed_archivereported a sub-millisecondNSDateas an exact timestamp when the binary plist's offset table runs into the trailer, a layout the keyed-archive preflight admits and plist@5 decodes. Expected output is the documented unknown date:iso8601: nullplus the unknown-date limitation.Change
scanBinaryPlistScalarsbounds offset-table reads by end of file instead of the trailer, matching decoder bounds. Strict callers are unchanged.Unsupported int size: 256. The offset width and both budget estimates now count the extra trailer.Unsupported int size: 0. That layout now keeps the generic incomplete-metadata disclosure.Evidence
KeyedArchiveReader.test.tscover the table running into the trailer: a sub-millisecond date, an overlapping date (Greptile's case), and an object in the trailer's spare bytes (Codex's case). All three fail on current main and pass here.src/artifacts/apple/andsrc/native/parsers/: 367 tests pass.keyedArchivePostTable.test.tsfrom fix(apple): preserve post-table plist objects #7820 passes. Typecheck, lint and format pass.npm run compile.Scope: a static parsing fix within existing boundaries, with no CLI/MCP contract, package or metadata change.
Author readiness
Human owner: @devreddy1015
Before merge
type(scope): outcome.