From 776cdd60fa9647ce5ee5f46408ab481ddf822f6c Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 30 Nov 2023 18:13:54 +1000 Subject: [PATCH] GzippedFileReader: Prevent out-of-bounds reads --- pcsx2/CDVD/GzippedFileReader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pcsx2/CDVD/GzippedFileReader.cpp b/pcsx2/CDVD/GzippedFileReader.cpp index b0dfa56a86358..795b1f5f99688 100644 --- a/pcsx2/CDVD/GzippedFileReader.cpp +++ b/pcsx2/CDVD/GzippedFileReader.cpp @@ -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);