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:
negativeExponent 2020-02-28 12:02:02 +08:00 committed by Rafael Kitover
parent fd319d2184
commit 9d1d707c01
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
1 changed files with 5 additions and 0 deletions

View File

@ -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) {