prevent overrunning the file buffer (eg: loading a game cover image

that's too big). increase buffer size to load larger IPS/UPS files.
This commit is contained in:
Daryl Borth 2018-08-27 09:30:31 -06:00
parent 0533d181a3
commit b4757544c9
2 changed files with 13 additions and 1 deletions

View File

@ -863,6 +863,18 @@ LoadFile (char * rbuffer, char *filepath, size_t length, bool silent)
size_t LoadFile(char * filepath, bool silent)
{
struct stat filestat;
if(stat(filepath, &filestat) != 0) {
return 0;
}
int size = filestat.st_size;
if(size >= SAVEBUFFERSIZE) {
return 0;
}
return LoadFile((char *)savebuffer, filepath, 0, silent);
}

View File

@ -21,7 +21,7 @@
#include <fat.h>
#include <unistd.h>
#define SAVEBUFFERSIZE (1024 * 512)
#define SAVEBUFFERSIZE (1024 * 1024 * 2) // leave room for IPS/UPS files and large images
void InitDeviceThread();
void ResumeDeviceThread();