MemoryCardFolder: Add missing bounds check to Read()

This commit is contained in:
Connor McLaughlin 2022-11-19 20:59:29 +10:00 committed by refractionpcsx2
parent 77ea599e36
commit 5ab4263c0a
1 changed files with 3 additions and 1 deletions

View File

@ -1008,7 +1008,9 @@ s32 FolderMemoryCard::Read(u8* dest, u32 adr, int size)
FolderMemoryCard::CalculateECC(ecc + (i * 3), &data[i * 0x80]);
}
memcpy(dest + eccOffset, ecc, eccLength);
pxAssert(size >= eccOffset);
const u32 copySize = std::min((u32)size - eccOffset, eccLength);
memcpy(dest + eccOffset, ecc, copySize);
}
SetTimeLastReadToNow();