Skip to content

ps2link: Fix IOP exception-report packet overflow - #67

Merged
fjtrujy merged 3 commits into
masterfrom
fix/iop-exception-packet-bounds
Oct 31, 2026
Merged

fjtrujy merged 3 commits into
masterfrom
fix/iop-exception-packet-bounds

Conversation

@fjtrujy

@fjtrujy fjtrujy commented Oct 31, 2026

Copy link
Copy Markdown
Member

Problem

The previous exception packet allocates sizeof(exception_frame_t) + 8 + 128 bytes, but writes an extra four-byte packet header before the frame. A 124-127-character IOP module name can therefore overrun the static buffer by up to four bytes during exception handling.

Fix

  • Replace offset arithmetic with a fixed-layout, 16-byte-aligned C packet structure, including command header, frame, relative EPC, name length and 128-byte name field.
  • Copy at most 127 module-name characters and always write the terminating NUL inside that field.
  • Preserve existing EE-side wire offsets (name at word 43) and RPC command format.
  • Add a portable C regression test for layout, short/empty/long names and boundary truncation; run it in GitHub Actions and block releases if it fails.

Validation

  • Native C layout/boundary test: passed.
  • Local PS2 SDK IOP + EE cross-build: passed (make -j4 LOADHIGH=0).
  • git diff --check: passed.
  • Real PS2 deliberate IOP exception tests remain recommended before merging.

Use an explicit, ABI-compatible wire packet struct that reserves the command header and a full 128-byte module name. Keep the EE offsets unchanged, cap and terminate names, and validate packet layout and boundary cases in portable C under CI.
@fjtrujy
fjtrujy merged commit 06a31aa into master Oct 31, 2026
5 checks passed
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.

1 participant