diff options
author | Ladislav Zezula <zezula@volny.cz> | 2023-09-23 01:08:58 +0200 |
---|---|---|
committer | Ladislav Zezula <zezula@volny.cz> | 2023-09-23 01:08:58 +0200 |
commit | cb56fff1a5aa1fd3b69c92c38dd07aec4ae28dec (patch) | |
tree | e9655958d759e8b8b1aa2258d5c6f3d917b40845 /src | |
parent | 8debce7eab1cfb7a145d592d757b75e7cac83610 (diff) |
StormLib will not make Warcraft III maps larger than 2GB
Diffstat (limited to 'src')
-rw-r--r-- | src/DllMain.rc | 24 | ||||
-rw-r--r-- | src/LibTomCrypt.c | 1 | ||||
-rw-r--r-- | src/SBaseCommon.cpp | 3 | ||||
-rw-r--r-- | src/SFileAddFile.cpp | 8 | ||||
-rw-r--r-- | src/StormLib.h | 4 | ||||
-rw-r--r-- | src/libtomcrypt/src/hashes/hash_memory.c | 69 | ||||
-rw-r--r-- | src/libtomcrypt/src/headers/tomcrypt_custom.h | 36 |
7 files changed, 43 insertions, 102 deletions
diff --git a/src/DllMain.rc b/src/DllMain.rc index 27f43e2..69b5cf0 100644 --- a/src/DllMain.rc +++ b/src/DllMain.rc @@ -16,10 +16,8 @@ // Neutral resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -#ifdef _WIN32 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #pragma code_page(1250) -#endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // @@ -27,8 +25,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL // VS_VERSION_INFO VERSIONINFO - FILEVERSION 9,22,0,3 - PRODUCTVERSION 9,22,0,3 + FILEVERSION 9,25,0,3 + PRODUCTVERSION 9,25,0,3 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -45,12 +43,12 @@ BEGIN BEGIN VALUE "Comments", "http://www.zezula.net/mpq.html" VALUE "FileDescription", "StormLib library for reading Blizzard MPQ archives" - VALUE "FileVersion", "9, 22, 0, 3\0" + VALUE "FileVersion", "9.25.0.3" VALUE "InternalName", "StormLib" - VALUE "LegalCopyright", "Copyright (c) 2014 - 2020 Ladislav Zezula" + VALUE "LegalCopyright", "Copyright (c) 2014 - 2023 Ladislav Zezula" VALUE "OriginalFilename", "StormLib.dll" VALUE "ProductName", "StormLib" - VALUE "ProductVersion", "9, 22, 0, 3\0" + VALUE "ProductVersion", "9.25.0.3" END END BLOCK "VarFileInfo" @@ -64,13 +62,11 @@ END ///////////////////////////////////////////////////////////////////////////// -// Czech resources +// Czech (Czech Republic) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) -#ifdef _WIN32 LANGUAGE LANG_CZECH, SUBLANG_DEFAULT #pragma code_page(1250) -#endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -78,26 +74,26 @@ LANGUAGE LANG_CZECH, SUBLANG_DEFAULT // TEXTINCLUDE // -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" END -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END #endif // APSTUDIO_INVOKED -#endif // Czech resources +#endif // Czech (Czech Republic) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/LibTomCrypt.c b/src/LibTomCrypt.c index 012f5e0..f77b604 100644 --- a/src/LibTomCrypt.c +++ b/src/LibTomCrypt.c @@ -8,6 +8,7 @@ #include "libtomcrypt/src/hashes/hash_memory.c" #include "libtomcrypt/src/hashes/md5.c" #include "libtomcrypt/src/hashes/sha1.c" +#include "libtomcrypt/src/hashes/sha256.c" #include "libtomcrypt/src/math/multi.c" #include "libtomcrypt/src/math/rand_prime.c" #include "libtomcrypt/src/misc/base64_decode.c" diff --git a/src/SBaseCommon.cpp b/src/SBaseCommon.cpp index b5b880e..664d4b0 100644 --- a/src/SBaseCommon.cpp +++ b/src/SBaseCommon.cpp @@ -244,8 +244,9 @@ void InitializeMpqCryptography() }
// Also register both MD5 and SHA1 hash algorithms
- register_hash(&md5_desc);
+ register_hash(&sha256_desc);
register_hash(&sha1_desc);
+ register_hash(&md5_desc);
// Use LibTomMath as support math library for LibTomCrypt
ltc_mp = ltm_desc;
diff --git a/src/SFileAddFile.cpp b/src/SFileAddFile.cpp index 5913424..2d14dda 100644 --- a/src/SFileAddFile.cpp +++ b/src/SFileAddFile.cpp @@ -246,6 +246,14 @@ static DWORD WriteDataToMpqFile( BSWAP_ARRAY32_UNSIGNED(pbToWrite, dwBytesInSector);
}
+ // Do not allow Warcraft III maps to go over 2GB.
+ // https://github.com/ladislav-zezula/StormLib/issues/306
+ if((ha->dwFlags & MPQ_FLAG_WAR3_MAP) && (ByteOffset + dwBytesInSector) > 0x7FFFFFFF)
+ {
+ dwErrCode = ERROR_DISK_FULL;
+ break;
+ }
+
// Write the file sector
if(!FileStream_Write(ha->pStream, &ByteOffset, pbToWrite, dwBytesInSector))
{
diff --git a/src/StormLib.h b/src/StormLib.h index 4d5992d..0bab24e 100644 --- a/src/StormLib.h +++ b/src/StormLib.h @@ -403,6 +403,10 @@ extern "C" { #define SHA1_DIGEST_SIZE 0x14 // 160 bits #endif +#ifndef SHA256_DIGEST_SIZE +#define SHA256_DIGEST_SIZE 0x20 // 256 bits +#endif + #ifndef LANG_NEUTRAL #define LANG_NEUTRAL 0x00 // Neutral locale #endif diff --git a/src/libtomcrypt/src/hashes/hash_memory.c b/src/libtomcrypt/src/hashes/hash_memory.c deleted file mode 100644 index 1daf0bf..0000000 --- a/src/libtomcrypt/src/hashes/hash_memory.c +++ /dev/null @@ -1,69 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file hash_memory.c - Hash memory helper, Tom St Denis -*/ - -/** - Hash a block of memory and store the digest. - @param hash The index of the hash you wish to use - @param in The data you wish to hash - @param inlen The length of the data to hash (octets) - @param out [out] Where to store the digest - @param outlen [in/out] Max size and resulting size of the digest - @return CRYPT_OK if successful -*/ -int hash_memory(int hash, const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen) -{ - hash_state *md; - int err; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - if ((err = hash_is_valid(hash)) != CRYPT_OK) { - return err; - } - - if (*outlen < hash_descriptor[hash].hashsize) { - *outlen = hash_descriptor[hash].hashsize; - return CRYPT_BUFFER_OVERFLOW; - } - - md = XMALLOC(sizeof(hash_state)); - if (md == NULL) { - return CRYPT_MEM; - } - - if ((err = hash_descriptor[hash].init(md)) != CRYPT_OK) { - goto LBL_ERR; - } - if ((err = hash_descriptor[hash].process(md, in, inlen)) != CRYPT_OK) { - goto LBL_ERR; - } - err = hash_descriptor[hash].done(md, out); - *outlen = hash_descriptor[hash].hashsize; -LBL_ERR: -#ifdef LTC_CLEAN_STACK - zeromem(md, sizeof(hash_state)); -#endif - XFREE(md); - - return err; -} - -/* $Source: /cvs/libtom/libtomcrypt/src/hashes/helper/hash_memory.c,v $ */ -/* $Revision: 1.6 $ */ -/* $Date: 2006/12/28 01:27:23 $ */ diff --git a/src/libtomcrypt/src/headers/tomcrypt_custom.h b/src/libtomcrypt/src/headers/tomcrypt_custom.h index 312a4c2..d53eef7 100644 --- a/src/libtomcrypt/src/headers/tomcrypt_custom.h +++ b/src/libtomcrypt/src/headers/tomcrypt_custom.h @@ -11,29 +11,29 @@ #define LTC_NO_ROLC #define LTC_SOURCE +#define LTC_SHA256 #define LTC_SHA1 #define LTC_MD5 #define LTC_DER -#define LTC_RC4 -#define USE_LTM #define LTM_DESC +#define USE_LTM /* macros for various libc functions you can change for embedded targets */ #ifndef XMALLOC - #ifdef malloc + #ifdef malloc #define LTC_NO_PROTOTYPES #endif #define XMALLOC LibTomMalloc #endif #ifndef XREALLOC - #ifdef realloc + #ifdef realloc #define LTC_NO_PROTOTYPES #endif #define XREALLOC LibTomRealloc #endif #ifndef XCALLOC - #ifdef calloc + #ifdef calloc #define LTC_NO_PROTOTYPES #endif #define XCALLOC LibTomCalloc @@ -58,7 +58,7 @@ #define XMEMCPY memcpy #endif #ifndef XMEMCMP - #ifdef memcmp + #ifdef memcmp #define LTC_NO_PROTOTYPES_MEMCMP #endif #define XMEMCMP memcmp @@ -91,19 +91,19 @@ #define LTC_BLOWFISH #define LTC_DES #define LTC_CAST5 - + #define LTC_NO_MODES #define LTC_ECB_MODE #define LTC_CBC_MODE #define LTC_CTR_MODE - + #define LTC_NO_HASHES #define LTC_SHA1 #define LTC_SHA512 #define LTC_SHA384 #define LTC_SHA256 #define LTC_SHA224 - + #define LTC_NO_MACS #define LTC_HMAC #define LTC_OMAC @@ -114,11 +114,11 @@ #define LTC_YARROW #define LTC_DEVRANDOM #define TRY_URANDOM_FIRST - + #define LTC_NO_PK #define LTC_MRSA #define LTC_MECC -#endif +#endif /* Use small code where possible */ /* #define LTC_SMALL_CODE */ @@ -194,7 +194,7 @@ #define LTC_LRW_MODE #ifndef LTC_NO_TABLES /* like GCM mode this will enable 16 8x128 tables [64KB] that make - * seeking very fast. + * seeking very fast. */ #define LRW_TABLES #endif @@ -205,7 +205,7 @@ #endif /* LTC_NO_MODES */ /* ---> One-Way Hash Functions <--- */ -#ifndef LTC_NO_HASHES +#ifndef LTC_NO_HASHES #define LTC_CHC_HASH #define LTC_WHIRLPOOL @@ -252,7 +252,7 @@ /* Use 64KiB tables */ #ifndef LTC_NO_TABLES - #define LTC_GCM_TABLES + #define LTC_GCM_TABLES #endif /* USE SSE2? requires GCC works on x86_32 and x86_64*/ @@ -319,7 +319,7 @@ #define LTC_MRSA /* Include Katja (a Rabin variant like RSA) */ -/* #define MKAT */ +/* #define MKAT */ /* Digital Signature Algorithm */ #define LTC_MDSA @@ -332,7 +332,7 @@ #if defined(TFM_LTC_DESC) && defined(LTC_MECC) #define LTC_MECC_ACCEL -#endif +#endif /* do we want fixed point ECC */ /* #define LTC_MECC_FP */ @@ -376,9 +376,9 @@ #ifdef LTC_MRSA #define LTC_PKCS_1 -#endif +#endif -#if defined(LTC_DER) && !defined(MPI) +#if defined(LTC_DER) && !defined(MPI) #error ASN.1 DER requires MPI functionality #endif |