Skip to content

Validate ST0010 command inputs before array access - #404

Open
acts-1631 wants to merge 1 commit into
bsnes-emu:masterfrom
acts-1631:fix/st0010-command-bounds
Open

acts-1631 wants to merge 1 commit into
bsnes-emu:masterfrom
acts-1631:fix/st0010-command-bounds

Conversation

@acts-1631

Copy link
Copy Markdown

ST0010::op_02() used a count supplied through emulated RAM to operate on two 32-entry tables without checking their capacity. Separately, op_01() normalized coordinates in 16-bit values, so negating -32768 could leave a negative index for the arctangent table. A crafted ST010 ROM could trigger native out-of-bounds accesses, potentially crashing or corrupting the emulator process.

Reject sort counts above the table capacity. Normalize coordinates and the quadrant in 32-bit temporaries before indexing the arctangent table, ensuring both indexes remain between 0 and 31.

ST0010 commands used a ROM-controlled sort count for two 32-entry tables
and normalized -32768 coordinates in int16 values. Crafted inputs could
therefore access memory outside the ST0010 object.

Reject sort counts above the table capacity and normalize coordinates in
32-bit temporaries before indexing the arctangent table.
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