Skip to content

Commit

Permalink
GzippedFileReader: Prevent out-of-bounds reads
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Nov 30, 2023
1 parent 234b3df commit 776cdd6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pcsx2/CDVD/GzippedFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ int GzippedFileReader::_ReadSync(void* pBuffer, s64 offset, uint bytesToRead)
if (!OkIndex(nullptr))
return -1;

if ((offset + bytesToRead) > m_pIndex->uncompressed_size)
return -1;

// Without all the caching, chunking and states, this would be enough:
// return extract(m_src, m_pIndex, offset, (unsigned char*)pBuffer, bytesToRead);

Expand Down

0 comments on commit 776cdd6

Please sign in to comment.