Repository navigation
Conversation
parseMachoLayout rejected any table with more than 4096 load commands as malformed bounds, even when the table was fully present and aligned. The shared cursor already bounds the walk by sizeofcmds, so drop the count operand and keep the out-of-file extent check. Fixes morluto#7696
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. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; no blocking issue was found. SummaryThis PR removes the 4096-command ceiling while keeping Mach-O framing checks. It also classifies malformed metadata as
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Read binary dispatch metadata] --> B{Result}
B -->|Success| C[Return validated metadata]
B -->|Unsupported capability, cleanup complete| D[Read symbols]
B -->|Other failure| E[Return binary reader error]
D --> F{Result}
F -->|Valid inventory| G[Return symbol-only metadata]
F -->|Failure or invalid inventory| H[Return fallback error with binary reader diagnostics]
Reviews (3) · Last reviewed commit: "fix(native): retain dispatch reader fail..." · Reviewed by Greptile |
…ack fails When the byte reader for inspect_native_dispatch_metadata refuses a target (for example a 32-bit Mach-O) and the list_names symbol fallback then fails or returns an invalid inventory, only the fallback's error reached the caller. Retain the reader failure under diagnostics.binary_metadata_failure. Fixes #7651. Carries forward e7884a7 (by @morluto, on @dreinst's #7701). Signed-off-by: Zhaowei Gu <[email protected]> Supersedes #8036 Co-authored-by: morluto <[email protected]> Co-Authored-By: gensokyo-dev <[email protected]>
…ack fails When the byte reader for inspect_native_dispatch_metadata refuses a target (for example a 32-bit Mach-O) and the list_names symbol fallback then fails or returns an invalid inventory, only the fallback's error reached the caller. Retain the reader failure under diagnostics.binary_metadata_failure. Fixes #7651. Carries forward e7884a7 (by @morluto, on @dreinst's #7701). Signed-off-by: Zhaowei Gu <[email protected]> Supersedes #8036 Co-authored-by: morluto <[email protected]> Co-Authored-By: gensokyo-dev <[email protected]>
…ack fails When the byte reader for inspect_native_dispatch_metadata refuses a target (for example a 32-bit Mach-O) and the list_names symbol fallback then fails or returns an invalid inventory, only the fallback's error reached the caller. Retain the reader failure under diagnostics.binary_metadata_failure. Fixes #7651. Carries forward e7884a7 (by @morluto, on @dreinst's #7701). Signed-off-by: Zhaowei Gu <[email protected]> Supersedes #8036 Co-authored-by: morluto <[email protected]> Co-Authored-By: gensokyo-dev <[email protected]>
Summary
Fixes #7696.
inspect-native-dispatch-metadatarejected a fully present, aligned Mach-O command table with 4097 commands asexecution_failure("Malformed Mach-O command bounds") and suggestedrea doctor. The same table with 4096 commands succeeded. It now decodes both.Problem and expected behavior
parseMachoLayout(src/native/AppleMachoSelection.ts) combined a hardcodedcommands > 4096check with the out-of-file extent check. Neither the Mach-O format, dyld's command walker nordocs/native-investigation.mddefines a 4096 command ceiling, so a count alone should not mark a walkable table as malformed.Change and scope
Drop the count operand and keep the extent check (
commandEnd > sliceEnd). The sharedMachoLoadCommandCursoralready proves framing: every command needs at least 8 bytes insidesizeofcmds, andfinish()requires bothncmdsandsizeofcmdsto be consumed exactly. A huge declaredncmdswith a smallsizeofcmdsstill stops at the first command beyond the declared bytes, so the walk stays bounded by the file budget.The related malformed and unsupported format refusals are now classified at the dispatch boundary as
unsupported_target, preserving their reasons rather than advising provider repair. Fixes #7652. Unexpected execution failures remain provider failures.Scope decision: not applicable (fix within an existing read-only static reader).
Contract and boundary impact
parseMachoLayoutadmission of the selected slice's command table; framing remains owned byMachoLoadCommandCursor. No superseded paths remain.execution_failure.Expected effects:
Evidence and regression coverage
src/native/AppleMachoSelection.test.tsadds a test that a 4097 commandLC_SOURCE_VERSIONtable parses, and that declaring 4097 commands with only 4096×16 bytes is still rejected (load command 4096 starts beyond sizeofcmds).> 4096check restored, the new test fails (executed).npm run build:cached,node scripts/rea.mjs inspect-native-dispatch-metadata <fixture> --format jsonexits 0 withobjc_classes: []for both 4096 and 4097 commands (executed).Boundary regressions covered: malformed framing (count beyond declared bytes) stays rejected; valid input above the former cap is accepted. No lifecycle stages involved.
Validation performed
npm run test:local -- src/native/AppleMachoSelection.test.ts src/native/AppleDispatchMetadata.test.ts src/domain/apple/machoLoadCommands.test.ts: 174 passednpm run check:fast: passednpm run build:cachedand the CLI comparison above: both fixtures exit 0Runs used Node.js v24.16.0 (dependencies installed with
npm ci --engine-strict=false), not the pinned 24.22.1.Follow-up validation for #7652
unsupported_targetwith its format reason.npm run check:fastandgit diff --checkpassed with pinned Node 24.22.1. MCP and real malformed binaries were not verified.Compatibility, safety, and release
unsupported_targetinstead ofexecution_failure. Clients matching error codes should account for this classification.sizeofcmdsand the file input budget.Related dispatch fallback failure (#7651)
If direct binary metadata reading fails and symbol fallback also fails or returns malformed output, the fallback error now retains the original reader failure alongside the fallback observation. The 32-bit reader refusal remains available instead of being lost.
Validation on this PR head:
npm run test:focused -- src/application/native/NativeDispatchMetadataInspection.fallback.test.ts tests/acceptance/nativeDispatchFallbackFailure.test.ts tests/boundary/cli/nativeDispatchFormatAdmission.test.tspassed 4 tests;npm run check:fastpassed. No real disassembler provider was used.Author readiness
Human owner:
Before merge
type(scope): outcome.