aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLadislav Zezula <ladislav.zezula@avg.com>2016-03-29 15:35:16 +0200
committerLadislav Zezula <ladislav.zezula@avg.com>2016-03-29 15:35:16 +0200
commit881ea60a0191188b18a07cbed448c1021bdbf7b5 (patch)
treece1ea1da44553bab781474fc1b3e7c3d10f58c8a /src
parented195c0d727ef4ea7d74d663b0f437bbac32233a (diff)
+ Fixed correction of table index
Diffstat (limited to 'src')
-rw-r--r--src/SBaseFileTable.cpp22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/SBaseFileTable.cpp b/src/SBaseFileTable.cpp
index 0b01cd0..43c68a0 100644
--- a/src/SBaseFileTable.cpp
+++ b/src/SBaseFileTable.cpp
@@ -591,10 +591,12 @@ static bool IsValidHashEntry1(TMPQArchive * ha, TMPQHash * pHash, TMPQBlock * pB
ULONGLONG ByteOffset;
TMPQBlock * pBlock = pBlockTable + pHash->dwBlockIndex;
- // Storm.dll does not perform this check. However, if there will
- // be an entry with (dwBlockIndex > dwBlockTableSize), the game would crash
- // Hence we assume that dwBlockIndex must be less than dwBlockTableSize
- if(pHash->dwBlockIndex < ha->pHeader->dwBlockTableSize)
+ // We need to mask out the upper 4 bits of the block table index.
+ // This is because it gets shifted out when calculating block table offset
+ // BlockTableOffset = pHash->dwBlockIndex * 0x10
+ // Malformed MPQ maps may contain invalid entries
+ // Note that Storm.dll does not perfom this check
+ if((pHash->dwBlockIndex & 0x0FFFFFFF) < ha->pHeader->dwBlockTableSize)
{
// Check whether this is an existing file
// Also we do not allow to be file size greater than 2GB
@@ -685,12 +687,6 @@ static TMPQHash * DefragmentHashTable(
// Parse the hash table and move the entries to the begin of it
for(pSource = pHashTable; pSource < pHashTableEnd; pSource++)
{
- // We need to mask out the upper 4 bits of the block table index.
- // This is because it gets shifted out when calculating block table offset
- // BlockTableOffset = pHash->dwBlockIndex * 0x10
- // Malformed MPQ maps may contain invalid entries
- pSource->dwBlockIndex &= 0x0FFFFFFF;
-
// Check whether this is a valid hash table entry
if(IsValidHashEntry1(ha, pSource, pBlockTable))
{
@@ -771,12 +767,6 @@ static int BuildFileTableFromBlockTable(
pHashTableEnd = ha->pHashTable + pHeader->dwHashTableSize;
for(pHash = ha->pHashTable; pHash < pHashTableEnd; pHash++)
{
- // We need to mask out the upper 4 bits of the block table index.
- // This is because it gets shifted out when calculating block table offset
- // BlockTableOffset = pHash->dwBlockIndex * 0x10
- // Malformed MPQ maps may contain invalid entries
- pHash->dwBlockIndex &= 0x0FFFFFFF;
-
//
// We need to properly handle these cases:
// - Multiple hash entries (same file name) point to the same block entry