Repository navigation
fix(iso9660): read the descriptor's root record from its fixed 34-byte field - #15002
Conversation
Codex Review Summary: ✅ CompletedThis 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. |
[Medium impact] The reviewed changes appear safe to merge. SummaryThe PR reads descriptor root records from their fixed 34-byte field while accepting larger declared lengths.
Reviews (2) · Last reviewed commit: "fix(iso9660): decode the descriptor root..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3eba997d43
ℹ️ 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".
|
Thanks @XiaoBinGan, the bug is real: requiring the descriptor's root record length byte to be exactly 34 rejects images that Linux, 7-Zip, libarchive and pycdlib all read. Could you rework the fix so it doesn't rewrite bytes before validation, though? The root cause is that A cleaner shape would be:
If you can find a real image that declares 36 or more, it would be great evidence. If not, please keep the validation gap noted in the PR body. |
The descriptor root is a fixed 34-byte field. Pass that extent to the shared record parser instead of copying the field and rewriting its length and identifier-length bytes. Accept identifier length 2 with bytes 00 00 only for an admitted Joliet descriptor.
|
@greptileai review |
|
The branch now carries the shape you asked for (
Verified on that head: On the real-image request: I have not found one that declares 36 or more. My reproduction is the repository fixture with the length byte changed, so the validation gap stays in the PR body: no disc image, no vendor medium, and extraction is covered only through the descriptor and tree parse, not end-to-end through |
Problem and outcome
parseIso9660VolumeDescriptorsrefused the whole image when a volume descriptor's root directory record declared a length other than 34. The descriptor reserves a fixed 34-byte field for that record — the volume set identifier always starts after it — and every common reader takes the record from the field rather than from the length byte.Measured on
origin/mainwith the repository's own ISO fixture, changing only the descriptor's length byte (offset156of the primary descriptor):Images in the wild declare 36 for a Joliet root whose NUL identifier is stored as UCS-2, and libarchive has seen up to 68. Such an image yields no inventory or extraction at all while Linux mounts it and 7-Zip, libarchive and pycdlib list it.
Evidence and validation
origin/mainas of the branch point. Head:3eba997d4onfix/iso9660-root-record-length.src/domain/iso9660: 23 tests pass.iso9660Structures.test.ts: declared lengths 36 and 48 on the primary descriptor parse; a Joliet root declaring 36 with identifier length 2 and bytes00 00parses; a declared length of 20 still reportsmalformedwith fieldroot_directory_record.iso9660VolumeDescriptors.tsfails the new case and nothing else.tsc0 errors;oxlint0 errors;oxfmt --checkclean; architecture guards pass across 3322 source files.Contract and boundary impact
A narrower refusal. The root record is decoded from the fixed 34-byte field with the field's own length, so every other root-record check — identifier
0x00, directory flag, single extent, volume sequence number, both-endian fields — is unchanged and still runs on the same bytes.A Joliet root whose identifier length is 2 with bytes
00 00is read as the single0x00byte the record is required to carry; that normalization happens on the descriptor's own 34-byte copy, so no shared record parser gains a mode and no other caller changes behaviour.A declared length below 34 stays malformed: it cannot hold the record's fixed fields, which is the bound libarchive also applies.
Unverified items
extract_artifact.Fixes #14802.
Author readiness
Human owner: @XiaoBinGan
Problem and outcome
parseIso9660VolumeDescriptorsrefused the whole image when a volume descriptor's root directory record declared a length other than 34. The descriptor reserves a fixed 34-byte field for that record — the volume set identifier always starts after it — and common readers take the record from the field rather than from the length byte.A Joliet root may store its NUL identifier as UCS-2 (length 2, bytes
00 00). libarchive has seen root records declared up to 68 bytes. Such an image yields no inventory or extraction at all while Linux mounts it and 7-Zip, libarchive and pycdlib list it.Evidence and validation
6d444991bacba0017f2e81103316e47e41804d4eonfix/iso9660-root-record-length.npm run test:focused -- src/domain/iso9660/iso9660Structures.test.ts src/artifacts/Iso9660ArtifactReader.test.ts src/artifacts/Iso9660ArtifactReader.boundaries.test.ts: 3 files, 105 tests passed.npm run check:fast: typecheck and lint succeeded; architecture guards passed across 3322 source files. The pre-push hook rancheck:fastagain and it succeeded from cache.src/domain/iso9660/iso9660Structures.test.ts(reads a root record from the descriptor's fixed 34-byte field) asserts structured root fields and typed failures: declared lengths 36 and 48 on the primary descriptor keep the parsed root; a Joliet root declaring 36 with identifier length 2 and bytes00 00keeps the Joliet root, including the one-byte identifier0x00; the same00 00identifier on the primary descriptor ismalformedwith fieldidentifier_length; a declared length of 20 ismalformedwith fieldroot_directory_record.Contract and boundary impact
The descriptor root is decoded from the fixed 34-byte field.
iso9660DirectoryRecordAttakes that extent as the record bound instead of the length byte, so the source bytes are not copied or rewritten. Directory extents still use the length byte; those callers are unchanged.A length-2 identifier
00 00is accepted only for an admitted Joliet descriptor, and it is read as the required one-byte identifier0x00. The primary descriptor still requires that single byte. A two-byte identifier does not fit the 34-byte field.A declared length below 34 stays malformed on
root_directory_record. Every other root-record check — directory flag, single extent, volume sequence number, both-endian fields — is unchanged and still runs on the field.Unverified items
00 00.extract_artifact.Fixes #14802.
Author readiness
Human owner: @XiaoBinGan