Skip to content

Fix standalone web UI crash when polling player data before ship selection#7367

Open
chief1983 wants to merge 1 commit intoscp-fs2open:masterfrom
chief1983:fix/7366-standalone-webui-poll-crash
Open

Fix standalone web UI crash when polling player data before ship selection#7367
chief1983 wants to merge 1 commit intoscp-fs2open:masterfrom
chief1983:fix/7366-standalone-webui-poll-crash

Conversation

@chief1983
Copy link
Copy Markdown
Member

playerGet() indexed Ship_info with ship_class without bounds checking. Before ship selection, ship_class is -1, which as an unsigned index causes an out-of-bounds access. Add the same bounds check that the Windows standalone GUI already has.

Fixes #7366

@wookieejedi wookieejedi added fix A fix for bugs, not-a-bugs, and/or regressions. multi A feature or issue related to the multiplayer code. labels Apr 9, 2026
@wookieejedi wookieejedi added this to the Release 25.0.1 milestone Apr 9, 2026
@wookieejedi
Copy link
Copy Markdown
Member

Reckon this is another one that would be great to have @notimaginative's take on.

json_object_set(obj, "observer", (MULTI_OBSERVER(p)) ? json_true() : json_false());
json_object_set(obj, "callsign", json_string(p.m_player->callsign));
json_object_set(obj, "ship", json_string(Ship_info[p.p_info.ship_class].name));
if (p.p_info.ship_class >= 0 && p.p_info.ship_class < static_cast<int>(Ship_info.size())) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe using ship_info_size() is the preferred way to do the upper bounds check. Otherwise this looks good to me.

Copy link
Copy Markdown
Member Author

@chief1983 chief1983 Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It had actually copied the pattern from the Windows stand_gui.cpp file, so guessing we could update that one as well?

1070 -  if (p->p_info.ship_class >= 0 && p->p_info.ship_class < static_cast<int>(Ship_info.size())) {
1070 +  if (p->p_info.ship_class >= 0 && p->p_info.ship_class < ship_info_size()) {

Went ahead and pushed a version with that change made.

…ction

playerGet() indexed Ship_info with ship_class without bounds checking.
Before ship selection, ship_class is -1, which as an unsigned index
causes an out-of-bounds access. Add bounds check using ship_info_size(),
matching the pattern used elsewhere in the codebase. Also update the
Windows standalone GUI to use ship_info_size() for consistency.

Fixes scp-fs2open#7366

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chief1983 chief1983 force-pushed the fix/7366-standalone-webui-poll-crash branch from 98e59d5 to 32f3369 Compare April 10, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions. multi A feature or issue related to the multiplayer code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standalone web UI crashes when polling player data before ship selection

3 participants