aboutsummaryrefslogtreecommitdiff
path: root/src/SBaseFileTable.cpp
diff options
context:
space:
mode:
authorGaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com>2023-01-07 21:53:35 +0100
committerGaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com>2023-01-07 21:53:35 +0100
commitd760fe6d41d6a9403c7e80d4a69f8808bdd29c25 (patch)
treef62b65571a69a948023e87c70fcf661778c980ec /src/SBaseFileTable.cpp
parent646c87e5b73c1d61720ad2d8b6e2f1f7a65642cf (diff)
MPQ_V4: Byteswap header after md5 is verified
Diffstat (limited to 'src/SBaseFileTable.cpp')
-rw-r--r--src/SBaseFileTable.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/SBaseFileTable.cpp b/src/SBaseFileTable.cpp
index a579fbd..2fd717b 100644
--- a/src/SBaseFileTable.cpp
+++ b/src/SBaseFileTable.cpp
@@ -651,7 +651,6 @@ DWORD ConvertMpqHeaderToFormat4(
// Verify header MD5. Header MD5 is calculated from the MPQ header since the 'MPQ\x1A'
// signature until the position of header MD5 at offset 0xC0
- BSWAP_TMPQHEADER(pHeader, MPQ_FORMAT_VERSION_4);
// Apparently, Starcraft II only accepts MPQ headers where the MPQ header hash matches
// If MD5 doesn't match, we ignore this offset. We also ignore it if there's no MD5 at all
@@ -660,6 +659,9 @@ DWORD ConvertMpqHeaderToFormat4(
if(!VerifyDataBlockHash(pHeader, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE, pHeader->MD5_MpqHeader))
return ERROR_FAKE_MPQ_HEADER;
+ // Byteswap after header MD5 is verified
+ BSWAP_TMPQHEADER(pHeader, MPQ_FORMAT_VERSION_4);
+
// HiBlockTable must be 0 for archives under 4GB
if((pHeader->ArchiveSize64 >> 0x20) == 0 && pHeader->HiBlockTablePos64 != 0)
return ERROR_FAKE_MPQ_HEADER;