Repository navigation
fix(native): reject required otool fields truncated before their value - #1995
Conversation
#1967 let requireUniqueField count a label at end of line so an empty dylib-use options row is present. That applied to every required field, so truncated output such as a bare vmaddr, vmsize, uuid or entryoff line passed the presence check while parseField dropped it, and the value silently became null. Let parseField decide which labeled line carries a value: the single matching line must parse as that field. The empty options row remains the only valueless field parseField admits. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27a4d14a01
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| throw new TypeError(`otool field ${key} is missing or repeated`); | ||
| // parseField owns which labeled lines carry a value; a bare required label | ||
| // is truncated output, except the empty dylib-use options row it admits. | ||
| if (parseField(lines[0] ?? "")?.[0] !== key) |
There was a problem hiding this comment.
Allow empty segment names in Mach-O object files
Mach-O MH_OBJECT files intentionally put their sections in an unnamed segment, and otool -l emits that as a bare segname row. Every segment validates segname through this helper, so this new check rejects otherwise valid object-file output as malformed and makes inspect_macho fail for those targets; the previous implementation retained the segment with an unknown name. Treat an empty segname as a valid textual value rather than as truncated output.
AGENTS.md reference: AGENTS.md:L23-L23
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed with a real clang -c object: otool -l prints its unnamed MH_OBJECT segment as a bare segname row, and this branch rejected it as unreadable. Fixed in ad89028. parseField now admits an empty segname alongside the empty dylib-use options row, and the projection still reports the empty name as "unknown", as main does. inspect-macho on that object now succeeds, with segment output identical to main. A truncated vmaddr in the same command is still rejected (new test in nativeLoadKinds.golden.test.ts). Full npm test: only this Mac's 12 environmental baseline failures.
MH_OBJECT files put their sections in one segment whose name is empty, and otool -l prints it as a bare segname label. Requiring a value for every scalar field rejected valid object-file output as unreadable. Let parseField admit an empty segname like the empty dylib-use options row, and keep projecting an empty or absent segment name as "unknown", as main did. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad890288ae
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (line === "options") return ["options", ""]; | ||
| // A dylib-use command with no flags still has an empty options row, and | ||
| // MH_OBJECT files put their sections in a segment with an empty segname. | ||
| if (line === "options" || line === "segname") return [line, ""]; |
There was a problem hiding this comment.
When otool reports an all-NUL section_64.sectname, it emits the same bare sectname row that this change already handles for segname. requireUniqueField now finds that label but parseField returns undefined, causing inspect_macho to reject an otherwise structurally readable Mach-O instead of retaining the section with its prior unknown name. Add sectname to the intentional empty-name handling (and project it to unknown) so this valid unknown value is preserved.
AGENTS.md reference: AGENTS.md:L23-L23
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 4e3cecf. parseField admits a bare sectname the same way as segname (both are fixed char[16] fields that may be all NUL), and the section projection keeps the empty name as "unknown", as main does. The object-file test now also covers an empty sectname, which fails without this change with otool field sectname has no value. The other string fields (name, path) always print an offset suffix, so they cannot appear bare. Full npm test: only this Mac's 12 environmental baseline failures.
An all-NUL section_64.sectname prints as a bare sectname label, like an empty segname. Admit it in parseField and keep projecting the empty name as "unknown", as main did. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fixes #1990
Behavior
#1967 changed
requireUniqueField's pattern to^\s*<key>(?:\s|$), so the empty dylib-useoptionsrow counts as present. The pattern applies to every required field. Truncatedotool -loutput with a barevmaddr,vmsize,uuidorentryofflabel therefore passed the presence check,parseFielddropped the line, and the value silently becamenull. A missing UUID then read as "no LC_UUID". Such output is now rejected withotool field <key> has no value, and an emptyoptionsrow is still accepted.Related cleanup
requireUniqueFieldused its own regex to decide which line holds a field. NowparseField, which already owns field-line parsing (including the empty-optionsexception), decides whether the single matching line carries a value. The label regex is still used only to detect missing or repeated labels, so the existingmissing or repeateddiagnostics are unchanged.Validation
tests/boundary/providers/native/nativeLoadKinds.golden.test.tstruncate one required value at a time in the realotool-load.txtcapture. All four fail on main (the output is accepted) and pass here. The existing empty-optionsand repeated-optionscases still pass.tests/boundary/providers/nativeandsrc/native: 319 passed. The one failure is the local hdiutil verify refusal, which also fails on main on this Mac.npm run lint,npm run typecheck,npm run format:check: pass.npm test: 8,500 passed, 12 failed. These are the same 12 that fail on a clean origin/main worktree on this Mac: ibtool NIB tests, the hdiutil verify refusal, and JS runtime paths under/private/var.otooloutput; the fixture is a real capture.🤖 Generated with Claude Code