Skip to content

ps2link: Harden TCP file-I/O socket lifecycle and malformed replies - #68

Merged
fjtrujy merged 2 commits into
masterfrom
fix/iop-fileio-connection-replies
Oct 31, 2026
Merged

fjtrujy merged 2 commits into
masterfrom
fix/iop-fileio-connection-replies

Conversation

@fjtrujy

@fjtrujy fjtrujy commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Problem

The IOP-side TCP file-I/O client could retain a stale socket after driver teardown or malformed replies. Wrong reply types/lengths leave unread bytes on the stream; zero-progress and oversized write counts were not consistently rejected.

Fix

  • Centralize descriptor detachment and disconnect for shutdown, reconnect and thread teardown; treat socket descriptor 0 as valid.
  • Reject mismatched packet types and sizes and close desynchronized TCP streams rather than attempting to continue.
  • Reject impossible read counts and zero/oversized successful write counts, while retaining valid short transfers and remote negative errors.
  • Add portable plain-C regression checks for descriptor invalidation, header validation and read/write bounds.
  • Keep the new CI job in its own workflow, independent of the exception-report fixes in ps2link: Fix IOP exception-report packet overflow #67. Either PR can merge first without conflicts.

Validation

  • Native C unit tests: passed.
  • PS2SDK IOP/EE default and LOADHIGH=1 ZEROCOPY=1 cross-builds: passed locally.
  • GitHub builds and native-C checks run on each push and PR.
  • git diff --check: passed.
  • Real PS2 reconnect/transfer testing is still recommended before merging.

This PR does not require any changes from #67 and does not alter the existing release job. The new check is independent and can be made a required status check in branch protection.

Share socket-detach cleanup across shutdown, connection replacement and EOF, close on malformed reply headers and impossible read/write lengths, and guard against zero-progress write replies. Add native C reply validation tests and CI gate.
@fjtrujy
fjtrujy merged commit 0d4aa7b into master Oct 31, 2026
6 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