Skip to content

fix(iso9660): read Joliet trees whose .. records name their own directory - #14817

Merged
morluto merged 2 commits into
morluto:mainfrom
Dev-next-gen:fix/iso9660-joliet-libisofs-parent
Nov 27, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
Dev-next-gen:fix/iso9660-joliet-libisofs-parent

Conversation

@Dev-next-gen

Copy link
Copy Markdown
Contributor

Summary

inspect-artifact and extract-artifact refuse every Joliet ISO written by libisofs, which is what xorriso -J and xorriso's mkisofs emulation produce. I hit it on the Alpine 3.21 release ISO (alpine-virt-3.21.3-x86_64.iso): the whole image is reported as malformed, so neither tree is listed and nothing can be extracted. No issue is linked; this PR carries the reproduction.

Problem and expected behavior

In a libisofs Joliet tree, each subdirectory's .. record carries the directory's own extent and length instead of its parent's. The cause is in libisofs write_one_dir_record() (libisofs/joliet.c, unchanged in 1.5.8): it reads block and len from the node, and only afterwards does if (file_id == 1 && node->parent) node = node->parent;, so only the timestamp and flags come from the parent. The primary tree written by the same library is correct.

assertMandatoryLink requires .. to match the parent's record, so the first Joliet subdirectory fails:

$ rea extract-artifact alpine-virt-3.21.3-x86_64.iso --output-root /tmp/x --json
Malformed iso9660 target for extract_artifact at alpine-virt-3.21.3-x86_64.iso: ISO 9660 image is malformed: the parent (..) record references block 40, not the parent directory's extent at block 39

Expected: the image is read like the same tree without Joliet, since the .. value is never used to find a directory (children are reached from their parent's records, and cycles are caught by the visited-extent set).

Change and scope

Iso9660DirectoryLinks gets an optional parentMayBeSelf. When it is set and the .. record's extent is the directory's own, the record is checked against the directory's own link (extent, data length, extended attribute length) instead of the parent's. The reader sets it only for the Joliet tree. The primary tree keeps the strict check, including the existing case in iso9660Structures.test.ts where a subdirectory's .. names itself. The ISO 9660 guide states the exception.

Not included: falling back to the primary tree when the Joliet tree is damaged in other ways.

Contract and boundary impact

  • Semantic owner and earliest changed stage: parseIso9660DirectoryExtent in src/domain/iso9660/iso9660Structures.ts; Iso9660ArtifactReader passes the tree kind.
  • Contribution scope fit and linked maintainer decision: not applicable, fix within the existing ISO 9660 reader.
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: ISO 9660 images with a Joliet tree written by libisofs now read instead of failing.
  • Evidence, artifact, provenance, or reconstruction contract: none changed; affected images now produce the usual inventory.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: Iso9660ArtifactReader.test.ts builds the Joliet fixture, rewrites each Joliet subdirectory's .. with its own extent and length as libisofs does, and checks that the tree and file bytes are read; the same rewrite in a primary-only image is still rejected as malformed.
  • Base reproduction or other evidence: on the base revision the new test fails with the parent (..) record references block 23, not the parent directory's extent at block 22. Through the compiled CLI, extract-artifact exits 1 with the error above on the Alpine 3.21.3 virt ISO and on two images I made with xorriso -as mkisofs -J (with and without -R). Images from the same tree without -J read fine on the base.
  • User-visible CLI/MCP output (if applicable): with the fix, extract-artifact exits 0 on all three: 119 files from the Alpine ISO, 306 from each xorriso image. For the -J -joliet-long image every extracted file has the same MD5 as the source tree.
  • Remaining proof gaps: I did not try Joliet images from other authoring tools (genisoimage, Windows IMAPI); the strict check still applies to any .. that names neither its parent nor itself.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run src/artifacts/Iso9660ArtifactReader.test.ts src/artifacts/Iso9660ArtifactReader.boundaries.test.ts src/domain/iso9660/iso9660Structures.test.ts: base 1 failed / 102 passed; fix 103 passed.
  • npm run compile, then node scripts/rea.mjs extract-artifact <iso> --output-root <dir> --json on the three ISOs: base exit 1 (malformed), fix exit 0 as above.
  • node scripts/run-typescript.mjs --noEmit: exit 0.
  • npx oxfmt --check on the changed files: clean. npx oxlint on them: 0 errors.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the relaxed check applies only in the Joliet tree and only when .. names the directory itself, which cannot introduce a new directory to walk; cycle and extent bounds checks are unchanged.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Author checklist (completed by the PR author before requesting review)

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
  • I ran every test, build, or measurement needed to validate this change, reported a browser, GPU, or environment gap only when that runtime or hardware is unavailable, and reported the checks I ran and their results without presenting inferred correctness or speedups as measured.
  • Comments explain constraints or non-obvious decisions; task history and conversations stay out of code and docs.
  • Documentation is concise and factual, without punchy slogans or promotional language.
  • This change fixes the root cause and follows the engineering rules in AGENTS.md.
  • Formatted input is interpreted once at the owning boundary, and consumers use the owner's parsed facts. See Interpret boundary facts once.
  • Combined failures preserve partial observations, remaining resources, and cleanup facts. See Own the lifecycle.
  • A hardcoded limit is an REA_ runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.

Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.5.

…tory

libisofs, behind xorriso and its mkisofs emulation, writes every Joliet
subdirectory's .. record with that directory's own extent and length:
write_one_dir_record() reads the block and length before it switches to
the parent node. The reader required .. to name the parent and refused the
whole image, so a Joliet ISO from xorriso -J, such as the Alpine 3.21
release ISOs, could be neither inspected nor extracted.

A Joliet tree now also accepts a .. record that describes the directory
itself. The primary tree keeps the strict check.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-27T00:49:31.050991Z
We couldn’t complete this review. Comment @codex review to try again.
fec983d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge, with the previous test coverage gap addressed.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the previous test coverage gap addressed.

Summary

The PR accepts Joliet .. records that describe their own directory while keeping primary-tree checks strict.

  • Joliet ISO trees can be read when their parent records point to themselves.

Reviews (4) · Last reviewed commit: "test(iso9660): check a self-describing J..." · Reviewed by Greptile

The reader test gives every directory the same data length and no
extended attribute record, so it would still pass if the relaxed check
compared those fields with the parent's. The parent link here differs in
both, and a self-describing .. carrying the parent's data length or
extended attribute length is rejected.
@morluto
morluto merged commit 55bb5e7 into morluto:main Nov 27, 2026
40 checks passed
vincentkoc added a commit that referenced this pull request Nov 27, 2026
…pgp-633-20261127

* commit '3097263763611eb0c32c502d5a222060cf02f468':
  fix(cli): describe universal Mach-O slice selection without a single-dash flag (#14912)
  fix(iso9660): read Joliet trees whose .. records name their own directory (#14817)
  feat(gpu)!: add per-call object, work, report, metadata, structure, and parser budgets to inspect_gpu_code_objects (#14882)
  fix(macho)!: select arm64e.x1 slices of universal Mach-O files by exact subtype (#14881)
  refactor(views): share bounded parent and report limitations (#14902)
  refactor(desktop): share XML parent pointers in task drafts (#14905)
  feat(ghidra): define function-pointer members and typedefs (#14889)
  refactor(setup): share publication destination checks (#14904)
  perf(ci): skip unused test runtime uploads (#14903)
  fix(nuget): preserve explicitly spaced publisher metadata (#14906)
  fix(artifacts): keep uImage coverage unknown when bytes follow the declared payload (#14896)
  fix(artifacts): report incomplete Android sparse coverage (#14883)
  fix(tar): require both end-of-archive blocks for complete coverage (#14884)
  refactor(views): centralize indexed row paging (#14878)
  refactor(views): reuse optional filters in report projections (#14877)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants