Skip to content

cdrom: fix cdread_2048 writing the sector header into the wrong buffer - #2068

Open
nicolasnoble wants to merge 1 commit into
grumpycoders:mainfrom
nicolasnoble:atapi-lua
Open

cdrom: fix cdread_2048 writing the sector header into the wrong buffer#2068
nicolasnoble wants to merge 1 commit into
grumpycoders:mainfrom
nicolasnoble:atapi-lua

Conversation

@nicolasnoble

Copy link
Copy Markdown
Member

cdread_2048 writes the sync pattern and MSF into the caller's dest, but the
mode byte, subheader and EDC/ECC into the member scratch m_cdbuffer. readTrack
passes m_cdbuffer as dest so the two alias there and it never showed; every
other caller, in practice every Lua read through CDRIsoFile, gets bytes 15..23
and the EDC/ECC tail as leftover garbage. GUESS then reads the bogus mode byte,
falls through to RAW, and hands back the sync pattern where user data should be.

Verified against an ISO9660 image: GUESS on sector 16 now returns the CD001
volume descriptor instead of the sync pattern.

cdread_2048 wrote the sync pattern and MSF into the caller-supplied dest,
but the mode byte, the Mode 2 subheader and the EDC/ECC into the member
scratch m_cdbuffer. readTrack passes m_cdbuffer as dest so the two alias
and the emulator's own path never noticed, but every other caller - which
in practice means every Lua caller going through CDRIsoFile - got bytes
15..23 and the EDC/ECC tail as whatever was left in its own buffer.

Visible effect: GUESS mode reads the garbage mode byte, falls through to
RAW, and hands back the sync pattern where user data was expected.

Signed-off-by: Nicolas 'Pixel' Noble <nicolas@nobis-crew.org>
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2da5bf34-019a-4f5c-9441-70dc6defb3e7

📥 Commits

Reviewing files that changed from the base of the PR and between 3e10093 and ab8e456.

📒 Files selected for processing (1)
  • src/cdrom/cdriso.cc

📝 Walkthrough

Walkthrough

cdread_2048 now writes generated sector headers and EDC/ECC data directly to the caller-provided dest buffer.

Changes

CD-ROM sector buffer generation

Layer / File(s) Summary
Generate sector data in destination buffer
src/cdrom/cdriso.cc
cdread_2048 writes sector header fields and computes EDC/ECC in dest instead of m_cdbuffer.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the buffer-writing defect, affected callers, resulting behavior, and verification.
Title check ✅ Passed The title clearly and concisely identifies the cdread_2048 buffer-writing defect.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant