mirror of
https://github.com/mupen64plus/mupen64plus-core.git
synced 2024-05-20 04:50:38 -04:00
Merge pull request #1059 from 269261/rom-size-checks
Add missing ROM file size checks
This commit is contained in:
commit
1656545339
|
@ -180,7 +180,8 @@ EXPORT m64p_error CALL CoreDoCommand(m64p_command Command, int ParamInt, void *P
|
|||
case M64CMD_ROM_OPEN:
|
||||
if (g_EmulatorRunning || l_DiskOpen || l_ROMOpen)
|
||||
return M64ERR_INVALID_STATE;
|
||||
if (ParamPtr == NULL || ParamInt < 4096)
|
||||
// ROM buffer size must be divisible by 4 to avoid out-of-bounds read in swap_copy_rom (v64/n64 formats)
|
||||
if (ParamPtr == NULL || ParamInt < 4096 || ParamInt > CART_ROM_MAX_SIZE || ParamInt % 4 != 0)
|
||||
return M64ERR_INPUT_ASSERT;
|
||||
rval = open_rom((const unsigned char *) ParamPtr, ParamInt);
|
||||
if (rval == M64ERR_SUCCESS)
|
||||
|
|
Loading…
Reference in a new issue