GBA: Disable more checks when loading GS save with checks disabled (fixes #1851)

This commit is contained in:
Vicki Pfau 2020-08-12 00:34:11 -07:00
parent 26427cf437
commit 5c1249f350
2 changed files with 3 additions and 2 deletions

View File

@ -39,6 +39,7 @@ Other fixes:
- Debugger: Don't skip undefined instructions when debugger attached
- FFmpeg: Fix some small memory leaks
- FFmpeg: Fix encoding of time base
- GBA: Disable more checks when loading GS save with checks disabled (fixes mgba.io/i/1851)
- Qt: Force OpenGL paint engine creation thread (fixes mgba.io/i/1642)
- Qt: Fix static compilation in MinGW (fixes mgba.io/i/1769)
- Qt: Fix a race condition in the frame inspector

View File

@ -69,7 +69,7 @@ bool GBASavedataImportSharkPort(struct GBA* gba, struct VFile* vf, bool testChec
return false;
}
LOAD_32(size, 0, &buffer.i);
if (size < 0x1C || size > SIZE_CART_FLASH1M + 0x1C) {
if (size < 0x1C || size >= SIZE_CART_FLASH1M + 0x1C) {
return false;
}
char* payload = malloc(size);
@ -91,7 +91,7 @@ bool GBASavedataImportSharkPort(struct GBA* gba, struct VFile* vf, bool testChec
buffer.c[0x19] = 0;
buffer.c[0x1A] = 0;
buffer.c[0x1B] = 0;
if (memcmp(buffer.c, payload, 0x1C) != 0) {
if (memcmp(buffer.c, payload, testChecksum ? 0x1C : 0xF) != 0) {
goto cleanup;
}