Skip to content

Reject malformed savestate container metadata - #2712

Open
acts-1631 wants to merge 1 commit into
melonDS-emu:masterfrom
acts-1631:fix/savestate-container-validation
Open

Reject malformed savestate container metadata#2712
acts-1631 wants to merge 1 commit into
melonDS-emu:masterfrom
acts-1631:fix/savestate-container-validation

Conversation

@acts-1631

Copy link
Copy Markdown

Savestate::FindSection previously trusted each on-disk section length when
advancing through the file. A zero-length record prevented the cursor from
advancing, causing state loading to loop indefinitely.

FIFO, DynamicFIFO, and RingBuffer also restored their count and cursor fields
without validating them against the container capacity. A malformed save state
could therefore leave a queue with invalid indices that were later used for
array access.

Reject truncated and invalid section records, and fail savestate loading when
restored FIFO metadata is outside the associated container bounds.

Savestate section lengths previously allowed zero-length records, causing
the section scanner to loop forever on a crafted state file. FIFO
metadata restored from a state file was also used without checking
that its count and indices fit the target container, allowing a
subsequent emulated FIFO write to access host memory out of bounds.

Reject truncated and invalid section records, and fail state loading
when restored FIFO metadata is outside the container bounds.
gajae1 added a commit to gajae1/melonDS that referenced this pull request Sep 7, 2026
… validation

Limit wrapped capture readback to the remaining blocks. Validate section headers and lengths before both returning a matching section and skipping one.

Reuse the one-line ARMJIT fix authored by Ogato in melonDS-emu#2654; its base ARMJIT.cpp blob matches this fork. The savestate work is informed by melonDS-emu#2712 but also validates matching sections before returning. FIFO validation from that PR is not included.

Add focused standalone C++ regression tests and a GCC/Clang sanitizer workflow. Document measurement-first performance direction without introducing a language rewrite or unmeasured SIMD requirements.

Locally verified: 7/7 CTest entries with GCC 14.2 and Clang 17 ASan/UBSan. These are dependency-isolated tests, not a complete emulator build, real OpenGL execution, or game/performance validation.
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