Skip to content

Fix remote crash from negative PlayerTypes in CvNetwork::receive() - #1227

Open
acato wants to merge 1 commit into
We-the-People-civ4col-mod:developfrom
acato:fix/network-negative-player-crash
Open

Fix remote crash from negative PlayerTypes in CvNetwork::receive()#1227
acato wants to merge 1 commit into
We-the-People-civ4col-mod:developfrom
acato:fix/network-negative-player-crash

Conversation

@acato

@acato acato commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a bounds check at the top of CvNetwork::receive() to reject invalid player IDs (< 0 or >= MAX_PLAYERS) before they reach the signed-to-unsigned comparison with vector::size()
  • Without this check, a negative ePlayer (e.g. NO_PLAYER = -1) is implicitly cast to ~4 billion when compared to the unsigned size_t, causing an infinite push_back loop that exhausts the 32-bit address space and crashes the game

Fixes #1225

Test plan

  • Verify multiplayer games still function normally (valid player IDs unaffected by the early return)
  • Confirm the fix compiles cleanly in Assert, Release, and FinalRelease targets

🤖 Generated with Claude Code

Reject invalid (negative or out-of-range) player IDs at the top of
the network receive handler. The signed-to-unsigned comparison with
vector::size() caused -1 to be interpreted as 4 billion, triggering
an infinite loop of push_back that exhausted the 32-bit address space.

Fixes We-the-People-civ4col-mod#1225

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Security: Negative PlayerTypes in CvNetwork::receive() causes remote crash in multiplayer

1 participant