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:34:42 -06:00
parent 633bca15af
commit 85217f4c0d
2 changed files with 13 additions and 1 deletions

View File

@ -871,6 +871,18 @@ LoadFile (char * rbuffer, char *filepath, size_t length, bool silent)
size_t LoadFile(char * filepath, 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); return LoadFile((char *)savebuffer, filepath, 0, silent);
} }

View File

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