Limit ROM size to 32 MiB.
Limit the utilLoad() function in src/Util.cpp to 32 MiB. This function loads a file from disk and returns a memory image of it. This is only used to load ROMs currently.
This commit is contained in:
parent
fd319d2184
commit
9d1d707c01
|
@ -60,6 +60,8 @@ static int(ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL;
|
|||
static int(ZEXPORT *utilGzCloseFunc)(gzFile) = NULL;
|
||||
static z_off_t(ZEXPORT *utilGzSeekFunc)(gzFile, z_off_t, int) = NULL;
|
||||
|
||||
#define MAX_CART_SIZE 0x2000000 // 32MB
|
||||
|
||||
bool FileExists(const char *filename)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -586,6 +588,9 @@ uint8_t *utilLoad(const char *file, bool (*accept)(const char *), uint8_t *data,
|
|||
if (size == 0)
|
||||
size = fileSize;
|
||||
|
||||
if (size > MAX_CART_SIZE)
|
||||
return NULL;
|
||||
|
||||
uint8_t *image = data;
|
||||
|
||||
if (image == NULL) {
|
||||
|
|
Loading…
Reference in New Issue