diff options
author | Ladislav Zezula <zezula@volny.cz> | 2024-04-21 22:35:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-21 22:35:07 +0200 |
commit | 3b65b373bc822a0ee0410edb80fa4ecfc0b454da (patch) | |
tree | 6d46b40a782aa282e60b3e9583d5a9120287c3b3 /src/SBaseCommon.cpp | |
parent | 605222393594f5885b877bfc0086dae756674965 (diff) | |
parent | 7250eca739f060dd6984b9ea74a9fbb8b0a7c353 (diff) |
Merge pull request #346 from ladislav-zezula/LZ_GabeShermanFoundBugs
Fixed bugs found by Gabe Sherman
Diffstat (limited to 'src/SBaseCommon.cpp')
-rw-r--r-- | src/SBaseCommon.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/SBaseCommon.cpp b/src/SBaseCommon.cpp index 587efe4..0de7864 100644 --- a/src/SBaseCommon.cpp +++ b/src/SBaseCommon.cpp @@ -1027,20 +1027,16 @@ void * LoadMpqTable( if(ByteOffset == SFILE_INVALID_POS)
FileStream_GetPos(ha->pStream, &ByteOffset);
- // On archives v 1.0, hash table and block table can go beyond EOF.
+ // The hash table and block table can go beyond EOF.
// Storm.dll reads as much as possible, then fills the missing part with zeros.
// Abused by Spazzler map protector which sets hash table size to 0x00100000
// Abused by NP_Protect in MPQs v4 as well
- if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1)
+ FileStream_GetSize(ha->pStream, &FileSize);
+ if((ByteOffset + dwBytesToRead) > FileSize)
{
- // Cut the table size
- FileStream_GetSize(ha->pStream, &FileSize);
- if((ByteOffset + dwBytesToRead) > FileSize)
- {
- // Fill the extra data with zeros
- dwBytesToRead = (DWORD)(FileSize - ByteOffset);
- memset(pbMpqTable + dwBytesToRead, 0, (dwTableSize - dwBytesToRead));
- }
+ // Fill the extra data with zeros
+ dwBytesToRead = (DWORD)(FileSize - ByteOffset);
+ memset(pbMpqTable + dwBytesToRead, 0, (dwTableSize - dwBytesToRead));
}
// Give the caller information that the table was cut
|