From f4e078a1a9fe28cf07da6f278a8a9428d581d780 Mon Sep 17 00:00:00 2001 From: JordanTheToaster Date: Fri, 4 Sep 2026 18:21:42 +0100 Subject: [PATCH] 3rdparty: Update LZMA/7zipSDK to 26.03 --- 3rdparty/lzma/include/7zTypes.h | 1 + 3rdparty/lzma/include/7zVersion.h | 6 +-- 3rdparty/lzma/include/Compiler.h | 30 +++++++++++++ 3rdparty/lzma/include/CpuArch.h | 11 +++++ 3rdparty/lzma/lzma-history.txt | 5 +++ 3rdparty/lzma/src/7zDec.c | 73 +++++++++++++++---------------- 3rdparty/lzma/src/Bcj2Enc.c | 7 ++- 3rdparty/lzma/src/Lzma2Enc.c | 22 +++------- 3rdparty/lzma/src/LzmaDec.c | 18 +++++--- 3rdparty/lzma/src/LzmaEnc.c | 13 ++++-- 3rdparty/lzma/src/Ppmd7Enc.c | 7 ++- 11 files changed, 123 insertions(+), 70 deletions(-) diff --git a/3rdparty/lzma/include/7zTypes.h b/3rdparty/lzma/include/7zTypes.h index 8aaabc8fbc..af47668055 100644 --- a/3rdparty/lzma/include/7zTypes.h +++ b/3rdparty/lzma/include/7zTypes.h @@ -556,6 +556,7 @@ struct ISzAlloc #define Z7_memset_0_ARRAY(a) memset((a), 0, sizeof(a)) +#define Z7_memset_0_VAR(a) memset(&(a), 0, sizeof(a)) #ifndef Z7_ARRAY_SIZE #define Z7_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) diff --git a/3rdparty/lzma/include/7zVersion.h b/3rdparty/lzma/include/7zVersion.h index 50ccebb475..de7efb8e3a 100644 --- a/3rdparty/lzma/include/7zVersion.h +++ b/3rdparty/lzma/include/7zVersion.h @@ -1,7 +1,7 @@ #define MY_VER_MAJOR 26 -#define MY_VER_MINOR 2 +#define MY_VER_MINOR 3 #define MY_VER_BUILD 0 -#define MY_VERSION_NUMBERS "26.02" +#define MY_VERSION_NUMBERS "26.03" #define MY_VERSION MY_VERSION_NUMBERS #ifdef MY_CPU_NAME @@ -10,7 +10,7 @@ #define MY_VERSION_CPU MY_VERSION #endif -#define MY_DATE "2026-06-25" +#define MY_DATE "2026-09-03" #undef MY_COPYRIGHT #undef MY_VERSION_COPYRIGHT_DATE #define MY_AUTHOR_NAME "Igor Pavlov" diff --git a/3rdparty/lzma/include/Compiler.h b/3rdparty/lzma/include/Compiler.h index c06b883665..707e46de05 100644 --- a/3rdparty/lzma/include/Compiler.h +++ b/3rdparty/lzma/include/Compiler.h @@ -125,6 +125,36 @@ typedef void (*Z7_void_Function)(void); #pragma warning(disable : 4464) // relative include path contains '..' #endif +// #define Z7_ANALYZE_MODE +#if defined(Z7_ANALYZE_MODE) // && defined(Z7_MSC_VER_ORIGINAL) +// for -analyze switch: +#if _MSC_VER >= 1900 +#pragma warning(disable : 6001) // Using uninitialized memory 'ps'. +#pragma warning(disable : 6031) // Return value ignored: 'CoInitialize' +#pragma warning(disable : 6553) // The annotation for function 'RegOpenKeyExW' on _Param_(3) does not apply to a value type. +#pragma warning(disable : 28159) // Random.cpp(21) : Consider using 'GetTickCount64' instead of 'GetTickCount' +#pragma warning(disable : 28160) // ProcessUtils.h(92) : Error annotation: Passing MEM_RELEASE and a non-zero dwSize parameter to VirtualFree is not allowed. This results in the failure of this call +#pragma warning(disable : 28251) // Inconsistent annotation for 'WinMain': this instance has no annotations. See c:\program files (x86)\windows kits\10\include\10.0.26100.0\um\winbase.h(1062). +#pragma warning(disable : 28286) // um\consoleapi.h(236) : For function 'ReadConsoleW', error near the end of 'SAL_readableTo(byteCount(*__formal(3,lpNumberOfCharsRead) * sizeof(TCHAR%)))'. +#pragma warning(disable : 28301) // No annotations for first declaration of 'PNTSTATUS'. See c:\program files (x86)\windows kits\10\include\10.0.26100.0\shared\bcrypt.h(40). +#endif +#if _MSC_VER >= 1600 +#pragma warning(disable : 6011) // Dereferencing NULL pointer 'p->IsDirs' +#pragma warning(disable : 6255) // `_alloca` indicates failure by raising a stack overflow exception. Consider using _malloca instead. +#pragma warning(disable : 6258) // Using TerminateThread does not allow proper thread clean up. +// #pragma warning(disable : 6262) // SfxSetup.c : Function uses '32808' bytes of stack. +#pragma warning(disable : 6320) // Threads.c : Exception-filter expression is the constant EXCEPTION_EXECUTE_HANDLER. This might mask exceptions that were not intended to be handled. +#pragma warning(disable : 6385) // createcoder.cpp : Invalid data: accessing 'struct CCodecInfo const * * g_Codecs', the readable size is '256' bytes, but '4194244' bytes might be read: Lines: 338, 339, 340, 342, 344 +#pragma warning(disable : 6387) // MyString.cpp : 's' could be '0': this does not adhere to the specification for the function 'wmemcpy' +#endif +#if _MSC_VER == 1600 +#pragma warning(disable : 6200) // compressdialog.cpp : Index '31' is out of valid index range '0' to '9' for non-stack buffer 'g_Levels' +#pragma warning(disable : 6204) // Possible buffer overrun in call to 'memset': use of unchecked parameter 'size' +#pragma warning(disable : 6309) // Argument '1' is null: this does not adhere to function specification of 'GetProcAddress' +#pragma warning(disable : 6386) // myvector.h : Buffer overrun: accessing 'argument 1', the writable size is 'newCapacity*4' bytes, but '8' bytes might be written +#endif +#endif // Z7_ANALYZE_MODE + // == 1200 : -O1 : for __forceinline // >= 1900 : -O1 : for printf #pragma warning(disable : 4710) // function not inlined diff --git a/3rdparty/lzma/include/CpuArch.h b/3rdparty/lzma/include/CpuArch.h index 348db0a4c9..e6698d881e 100644 --- a/3rdparty/lzma/include/CpuArch.h +++ b/3rdparty/lzma/include/CpuArch.h @@ -209,6 +209,17 @@ MY_CPU_64BIT means that processor can work with 64-bit registers. #endif +#if defined(__s390__) +#if defined(__s390x__) || defined(__LP64__) || (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8) + #define MY_CPU_NAME "s390x" + #define MY_CPU_SIZEOF_POINTER 8 +#else + #define MY_CPU_NAME "s390" + #define MY_CPU_SIZEOF_POINTER 4 +#endif +#endif + + // #undef MY_CPU_NAME // #undef MY_CPU_SIZEOF_POINTER // #define __e2k__ diff --git a/3rdparty/lzma/lzma-history.txt b/3rdparty/lzma/lzma-history.txt index 995cadb7f1..9954f71b12 100644 --- a/3rdparty/lzma/lzma-history.txt +++ b/3rdparty/lzma/lzma-history.txt @@ -1,6 +1,11 @@ ISTORY of the LZMA SDK ----------------------- +26.03 2026-09-03 +------------------------- +- Some bugs and vulnerabilities were fixed. + + 26.02 2026-06-25 ------------------------- - Some bugs and vulnerabilities were fixed. diff --git a/3rdparty/lzma/src/7zDec.c b/3rdparty/lzma/src/7zDec.c index 520cbfd833..1149d06091 100644 --- a/3rdparty/lzma/src/7zDec.c +++ b/3rdparty/lzma/src/7zDec.c @@ -99,62 +99,61 @@ static Byte ReadByte(IByteInPtr pp) static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStreamPtr inStream, Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) { - CPpmd7 ppmd; - CByteInToLook s; - SRes res = SZ_OK; - - s.vt.Read = ReadByte; - s.inStream = inStream; - s.begin = s.end = s.cur = NULL; - s.extra = False; - s.res = SZ_OK; - s.processed = 0; + CPpmd7 *ppmd; + SRes res; + unsigned order; + UInt32 memSize; if (propsSize != 5) return SZ_ERROR_UNSUPPORTED; + order = props[0]; + memSize = GetUi32(props + 1); + if (order < PPMD7_MIN_ORDER || + order > PPMD7_MAX_ORDER || + memSize < PPMD7_MIN_MEM_SIZE || + memSize > PPMD7_MAX_MEM_SIZE) + return SZ_ERROR_UNSUPPORTED; + if ((ppmd = (CPpmd7 *)ISzAlloc_Alloc(allocMain, sizeof(CPpmd7))) == NULL) + return SZ_ERROR_MEM; + Ppmd7_Construct(ppmd); + res = SZ_ERROR_MEM; + if (Ppmd7_Alloc(ppmd, memSize, allocMain)) + { + CByteInToLook s; + s.vt.Read = ReadByte; + s.inStream = inStream; + s.begin = s.end = s.cur = NULL; + s.extra = False; + s.res = SZ_OK; + s.processed = 0; - { - unsigned order = props[0]; - UInt32 memSize = GetUi32(props + 1); - if (order < PPMD7_MIN_ORDER || - order > PPMD7_MAX_ORDER || - memSize < PPMD7_MIN_MEM_SIZE || - memSize > PPMD7_MAX_MEM_SIZE) - return SZ_ERROR_UNSUPPORTED; - Ppmd7_Construct(&ppmd); - if (!Ppmd7_Alloc(&ppmd, memSize, allocMain)) - return SZ_ERROR_MEM; - Ppmd7_Init(&ppmd, order); - } - { - ppmd.rc.dec.Stream = &s.vt; - if (!Ppmd7z_RangeDec_Init(&ppmd.rc.dec)) - res = SZ_ERROR_DATA; - else if (!s.extra) + Ppmd7_Init(ppmd, order); + ppmd->rc.dec.Stream = &s.vt; + res = SZ_ERROR_DATA; + if (Ppmd7z_RangeDec_Init(&ppmd->rc.dec) && !s.extra) { Byte *buf = outBuffer; const Byte *lim = buf + outSize; for (; buf != lim; buf++) { - int sym = Ppmd7z_DecodeSymbol(&ppmd); + int sym = Ppmd7z_DecodeSymbol(ppmd); if (s.extra || sym < 0) break; *buf = (Byte)sym; } - if (buf != lim) - res = SZ_ERROR_DATA; - else if (!Ppmd7z_RangeDec_IsFinishedOK(&ppmd.rc.dec)) - { - /* if (Ppmd7z_DecodeSymbol(&ppmd) != PPMD7_SYM_END || !Ppmd7z_RangeDec_IsFinishedOK(&ppmd.rc.dec)) */ - res = SZ_ERROR_DATA; - } + if (buf == lim) + if (Ppmd7z_RangeDec_IsFinishedOK(&ppmd->rc.dec) + // || (Ppmd7z_DecodeSymbol(&ppmd) == PPMD7_SYM_END && Ppmd7z_RangeDec_IsFinishedOK(&ppmd.rc.dec)) + ) + res = SZ_OK; } if (s.extra) res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA); else if (s.processed + (size_t)(s.cur - s.begin) != inSize) res = SZ_ERROR_DATA; + Ppmd7_Free(ppmd, allocMain); } - Ppmd7_Free(&ppmd, allocMain); + ISzAlloc_Free(allocMain, ppmd); return res; } diff --git a/3rdparty/lzma/src/Bcj2Enc.c b/3rdparty/lzma/src/Bcj2Enc.c index 79460bb150..5727cbb2dc 100644 --- a/3rdparty/lzma/src/Bcj2Enc.c +++ b/3rdparty/lzma/src/Bcj2Enc.c @@ -1,5 +1,5 @@ /* Bcj2Enc.c -- BCJ2 Encoder converter for x86 code (Branch CALL/JUMP variant2) -2023-04-02 : Igor Pavlov : Public domain */ +: Igor Pavlov : Public domain */ #include "Precomp.h" @@ -75,7 +75,10 @@ static BoolInt Bcj2_RangeEnc_ShiftLow(CBcj2Enc *p) p->cache = (Byte)(low >> 24); } p->cacheSize++; - p->low = low << 8; + { + const UInt32 low2 = low << 8; + p->low = low2; + } return False; } diff --git a/3rdparty/lzma/src/Lzma2Enc.c b/3rdparty/lzma/src/Lzma2Enc.c index 72aec69533..5d64828c4c 100644 --- a/3rdparty/lzma/src/Lzma2Enc.c +++ b/3rdparty/lzma/src/Lzma2Enc.c @@ -129,11 +129,10 @@ UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle p); static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf, size_t *packSizeRes, ISeqOutStreamPtr outStream) { - size_t packSizeLimit = *packSizeRes; + const size_t packSizeLimit = *packSizeRes; size_t packSize = packSizeLimit; UInt32 unpackSize = LZMA2_UNPACK_SIZE_MAX; - unsigned lzHeaderSize = 5 + (p->needInitProp ? 1 : 0); - BoolInt useCopyBlock; + const unsigned lzHeaderSize = 5 + (p->needInitProp ? 1 : 0); SRes res; *packSizeRes = 0; @@ -150,22 +149,13 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf, if (unpackSize == 0) return res; - if (res == SZ_OK) - useCopyBlock = (packSize + 2 >= unpackSize || packSize > (1 << 16)); - else - { - if (res != SZ_ERROR_OUTPUT_EOF) - return res; - res = SZ_OK; - useCopyBlock = True; - } - - if (useCopyBlock) + if (res == SZ_ERROR_OUTPUT_EOF + || (res == SZ_OK && (packSize + 2 >= unpackSize || packSize > (1 << 16)))) { size_t destPos = 0; PRF(printf("################# COPY ")); - while (unpackSize > 0) + while (unpackSize) { const UInt32 u = (unpackSize < LZMA2_COPY_CHUNK_SIZE) ? unpackSize : LZMA2_COPY_CHUNK_SIZE; if (packSizeLimit - destPos < u + 3) @@ -194,6 +184,8 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf, return SZ_OK; } + if (res != SZ_OK) + return res; { size_t destPos = 0; const UInt32 u = unpackSize - 1; diff --git a/3rdparty/lzma/src/LzmaDec.c b/3rdparty/lzma/src/LzmaDec.c index 69bb8bba9d..5bc5094cd5 100644 --- a/3rdparty/lzma/src/LzmaDec.c +++ b/3rdparty/lzma/src/LzmaDec.c @@ -1,5 +1,5 @@ /* LzmaDec.c -- LZMA Decoder -2023-04-07 : Igor Pavlov : Public domain */ +: Igor Pavlov : Public domain */ #include "Precomp.h" @@ -462,8 +462,10 @@ int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit) if (state >= kNumStates) { UInt32 distance; - prob = probs + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); + { + const unsigned temp = (len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits; + prob = probs + PosSlot + temp; + } TREE_6_DECODE(prob, distance) if (distance >= kStartPosModelIndex) { @@ -857,9 +859,10 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byt if (state < 4) { unsigned posSlot; - prob = probs + PosSlot + - ((len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) << - kNumPosSlotBits); + { + const unsigned temp = (len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) << kNumPosSlotBits; + prob = probs + PosSlot + temp; + } TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot) if (posSlot >= kStartPosModelIndex) { @@ -867,7 +870,8 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byt if (posSlot < kEndPosModelIndex) { - prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits); + const unsigned temp = (2 | (posSlot & 1)) << numDirectBits; + prob = probs + SpecPos + temp; } else { diff --git a/3rdparty/lzma/src/LzmaEnc.c b/3rdparty/lzma/src/LzmaEnc.c index 60f1d21da4..f54e670149 100644 --- a/3rdparty/lzma/src/LzmaEnc.c +++ b/3rdparty/lzma/src/LzmaEnc.c @@ -692,7 +692,10 @@ Z7_NO_INLINE static void Z7_FASTCALL RangeEnc_ShiftLow(CRangeEnc *p) { UInt32 low = (UInt32)p->low; unsigned high = (unsigned)(p->low >> 32); - p->low = (UInt32)(low << 8); + { + const UInt32 low2 = low << 8; + p->low = low2; + } if (low < (UInt32)0xFF000000 || high != 0) { { @@ -958,7 +961,8 @@ static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned sym, unsigned posS unsigned m; unsigned bit; RC_BIT_0(rc, probs) - probs += (posState << (1 + kLenNumLowBits)); + posState <<= (1 + kLenNumLowBits); + probs += posState; bit = (sym >> 2) ; RC_BIT(rc, probs + 1, bit) m = (1 << 1) + bit; bit = (sym >> 1) & 1; RC_BIT(rc, probs + m, bit) m = (m << 1) + bit; bit = sym & 1; RC_BIT(rc, probs + m, bit) @@ -1000,7 +1004,8 @@ Z7_NO_INLINE static void Z7_FASTCALL LenPriceEnc_UpdateTables( for (posState = 0; posState < numPosStates; posState++) { UInt32 *prices = p->prices[posState]; - const CLzmaProb *probs = enc->low + (posState << (1 + kLenNumLowBits)); + const unsigned posState2 = posState << (1 + kLenNumLowBits); + const CLzmaProb *probs = enc->low + posState2; SetPrices_3(probs, a, prices, ProbPrices); SetPrices_3(probs + kLenNumLowSymbols, c, prices + kLenNumLowSymbols, ProbPrices); } @@ -2220,7 +2225,7 @@ Z7_NO_INLINE static void FillAlignPrices(CLzmaEnc *p) UInt32 prob; bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; + bit = sym & 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; prob = probs[m]; p->alignPrices[i ] = price + GET_PRICEa_0(prob); p->alignPrices[i + 8] = price + GET_PRICEa_1(prob); diff --git a/3rdparty/lzma/src/Ppmd7Enc.c b/3rdparty/lzma/src/Ppmd7Enc.c index 49cbbe6499..975157c9b3 100644 --- a/3rdparty/lzma/src/Ppmd7Enc.c +++ b/3rdparty/lzma/src/Ppmd7Enc.c @@ -1,5 +1,5 @@ /* Ppmd7Enc.c -- Ppmd7z (PPMdH with 7z Range Coder) Encoder -2023-09-07 : Igor Pavlov : Public domain +: Igor Pavlov : Public domain This code is based on: PPMd var.H (2001): Dmitry Shkarin : Public domain */ @@ -35,7 +35,10 @@ static void Ppmd7z_RangeEnc_ShiftLow(CPpmd7 *p) R->Cache = (Byte)((UInt32)R->Low >> 24); } R->CacheSize++; - R->Low = (UInt32)((UInt32)R->Low << 8); + { + const UInt32 low2 = (UInt32)R->Low << 8; + R->Low = low2; + } } #define RC_NORM_BASE(p) if (R->Range < kTopValue) { R->Range <<= 8; Ppmd7z_RangeEnc_ShiftLow(p);