Skip to content

Validate pad transfer state when loading savestates - #189

Merged
LibretroAdmin merged 1 commit into
libretro:mainfrom
acts-1631:fix-pad-state-validation
Oct 15, 2026
Merged

LibretroAdmin merged 1 commit into
libretro:mainfrom
acts-1631:fix-pad-state-validation

Conversation

@acts-1631

Copy link
Copy Markdown
Contributor

HostInterface::retro_unserialize() passes rollback states through System::LoadState() into Pad::DoState(). Multitap::DoState() restored m_controller_transfer_step without checking it against the 32-byte transfer buffer. Multitap::Transfer() subsequently used it for both reads and writes. A crafted netplay rollback state could therefore crash the frontend or corrupt adjacent host memory on the next pad transfer.

AnalogController::DoState() and NeGconRumble::DoState() also restored an active command without restoring its command step, response length, or response buffers. A crafted state could enter an active command with a zero response length and cause division by zero in Transfer().

Validate multitap transfer state and reset it before rejecting invalid values. End all-controller responses based on the transfer buffer length rather than derived slot state. Since the analog controller state format does not contain the transient fields needed to resume an in-progress command, reset that command state after loading while preserving the controller configuration.

Savestates can supply an out-of-range multitap transfer index,
which the all-controller path uses to access its fixed response
buffer. Analog controllers also restore commands without the
transient state required to execute them.

Validate and reset invalid multitap state, finish transfers at the
buffer boundary, and discard incomplete analog command state after
loading. This prevents crafted states from causing out-of-bounds
accesses or division by zero during later pad traffic.
@LibretroAdmin
LibretroAdmin merged commit 139de47 into libretro:main Oct 15, 2026
3 checks 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