Skip to content

P1: Fix various crash potentials in table and mission parsing - #7907

Open
dustinspace217 wants to merge 1 commit into
scp-fs2open:masterfrom
dustinspace217:parse/bound-text-reads
Open

dustinspace217 wants to merge 1 commit into
scp-fs2open:masterfrom
dustinspace217:parse/bound-text-reads

Conversation

@dustinspace217

Copy link
Copy Markdown
Contributor

What?

A handful of small fixes in the table and mission parsers and the weapon loadout screen, where malformed text could crash the game.

Why?

A malformed table, mission or weapon description could crash the game while loading or on the loadout screen. Valid data behaves the same, apart from the two visible differences listed below.

How?

  • Version-specific comment tags (;;FSO x.y;;) without their closing semicolons are treated as ordinary comments.
  • get_string now honors its length limit and stops cleanly at a missing closing quote or the end of the file, and the mission parser passes the buffer size where it reads into a fixed buffer.
  • A mission variable with an out-of-range index is placed in the next free slot with a warning (block variables are skipped), and the variable count returned to the mission loader always covers exactly the slots in use.
  • The loadout screen keeps weapon descriptions and titles inside their display buffers, and the description line limit warning matches what the screen shows.

Testing?

  • Debug builds with AddressSanitizer on master and this branch, with a small test mod holding a table, two missions and a weapon description that exercise each case (MediaVPs 5.0.2, SM1-01). Master crashed or failed a check on each; this branch loads them with warnings and shows the loadout screen normally.
  • Regression: SM1-01 and loop2-2 on OpenGL and Vulkan, master vs branch screenshots and debug logs.
  • Release and Debug builds, the unit tests, and CI's clang-tidy job in its own container.

Anything Else?

Two visible changes: a mission variable name longer than 31 characters is now cut with a warning (it used to stop the game with an error), and the fifth weapon description line now stays visible after the loadout text animation finishes (it used to disappear).

I used Claude Code to help find and test this.

Version-specific comment tags, length-limited quoted strings, mission
variable names and indices, and loadout weapon descriptions are now kept
within their buffers. Malformed input produces a warning; valid tables and
missions load as before.
@BMagnu BMagnu added fix A fix for bugs, not-a-bugs, and/or regressions. LLM-authored For PR's mainly created through LLMs and NOT submitted by badged developers LLM-suggested PRs made not by an observed bug or a human feature request, but by discovery of something by an LLM labels Oct 19, 2026
@dustinspace217 dustinspace217 changed the title Fix various crash potentials in table and mission parsing P1: Fix various crash potentials in table and mission parsing Oct 19, 2026
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. LLM-authored For PR's mainly created through LLMs and NOT submitted by badged developers LLM-suggested PRs made not by an observed bug or a human feature request, but by discovery of something by an LLM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants