+ Fixed arbitrarily large allocations caused by TQMPHeader::dwBlockTableSize

This commit is contained in:
Zezula Ladislav
2018-10-15 11:23:52 +02:00
parent 4ad0bff21d
commit f35d106059
6 changed files with 50 additions and 15 deletions

View File

@@ -406,6 +406,14 @@ int ConvertMpqHeaderToFormat4(
pHeader->ArchiveSize64 = DetermineArchiveSize_V1(ha, pHeader, MpqOffset, FileSize);
pHeader->dwArchiveSize = (DWORD)pHeader->ArchiveSize64;
}
// EWIX_v8_7.w3x: TMPQHeader::dwBlockTableSize = 0x00319601
// Size of TFileTable goes to ~200MB, so we artificially cut it
if(BlockTablePos64 + (pHeader->dwBlockTableSize * sizeof(TMPQBlock)) > FileSize)
{
pHeader->dwBlockTableSize = (DWORD)((FileSize - BlockTablePos64) / sizeof(TMPQBlock));
pHeader->BlockTableSize64 = pHeader->dwBlockTableSize * sizeof(TMPQBlock);
}
break;
case MPQ_FORMAT_VERSION_2: