Skip to content

Commit

Permalink
FS: fix crash overreading data on flash0
Browse files Browse the repository at this point in the history
noticed while using intrafont with some homebrew code.
when using musl libc's hardened malloc, the overread in the
code caused PPSSPP to segfault.
  • Loading branch information
rofl0r committed Feb 26, 2024
1 parent 3d58d1f commit 55ae3b1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Core/FileSystems/DirectoryFileSystem.cpp
Expand Up @@ -1067,6 +1067,9 @@ size_t VFSFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) {
EntryMap::iterator iter = entries.find(handle);
if (iter != entries.end())
{
if(iter->second.seekPos + size > iter->second.size)
size = iter->second.size - iter->second.seekPos;
if(size < 0) size = 0;
size_t bytesRead = size;
memcpy(pointer, iter->second.fileData + iter->second.seekPos, size);
iter->second.seekPos += size;
Expand Down

0 comments on commit 55ae3b1

Please sign in to comment.