aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLadislav Zezula <zezula@volny.cz>2023-01-09 08:46:31 +0100
committerGitHub <noreply@github.com>2023-01-09 08:46:31 +0100
commit05d0f04c07a56618bf0a6a0652622b5e9a69d8ce (patch)
treef62b65571a69a948023e87c70fcf661778c980ec
parent646c87e5b73c1d61720ad2d8b6e2f1f7a65642cf (diff)
parentd760fe6d41d6a9403c7e80d4a69f8808bdd29c25 (diff)
Merge pull request #280 from GaryOderNichts/fix/v4_header_md5_bswap
Merged. Thanks for the bug fix 👍
-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;