Skip to content

Fix off-by-one in RadarMap radarcol bounds checks - #87

Merged
kaczy93 merged 1 commit into
kaczy93:masterfrom
DavideRei:fix-radarmap-bounds
Nov 23, 2026
Merged

kaczy93 merged 1 commit into
kaczy93:masterfrom
DavideRei:fix-radarmap-bounds

Conversation

@DavideRei

Copy link
Copy Markdown
Contributor

Problem

RadarMap reads _radarColors[id] after a bounds check that lets id == _radarColors.Length through (> instead of >=). A static whose radar index (Id + 0x4000) is exactly the length of radarcol, with Z at or above the land, makes the server throw IndexOutOfRangeException at startup.

RadarMap.Update has no check at all, so editing a tile with such an id (or any id past the end) throws from the packet handler and the client is disconnected; during a large scale operation it aborts the operation.

Fix

  • Constructor: >= instead of >.
  • Update: the same check, with the same log line and 0x4000 fallback.

Testing

  • Reproduced both exceptions with synthetic map/statics/radarcol files loaded through ServerLandscape (radarcol of 0x4001, 0x8000 and 0xC000 entries), and checked they are gone. Valid ids keep their color.
  • Solution builds; Shared.Tests and CentrED.Tests pass.

🤖 Generated with Claude Code

The constructor checked `id > _radarColors.Length` before reading
`_radarColors[id]`, so a static whose radar index equals the length of
radarcol threw IndexOutOfRangeException at server startup. Use `>=`.

RadarMap.Update had no check at all, so editing such a tile (or one
past the end) threw from the packet handler. Apply the same check and
fallback there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaczy93
kaczy93 merged commit b523e40 into kaczy93:master Nov 23, 2026
1 check 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.

2 participants