From f9d78aff31a5f2521ae7ddbdc97c4a8855808959 Mon Sep 17 00:00:00 2001 From: Igor Pavlov <87184205+ip7z@users.noreply.github.com> Date: Thu, 25 Jun 2026 00:00:00 +0000 Subject: [PATCH] 26.02 --- C/7zArcIn.c | 653 ++++++++---------- C/7zVersion.h | 6 +- C/Compiler.h | 5 + C/DllSecur.c | 6 +- C/MtDec.c | 4 +- C/Util/7z/7zMain.c | 7 +- C/Util/7zipInstall/7zipInstall.c | 38 +- C/Util/7zipUninstall/7zipUninstall.c | 58 +- C/Util/SfxSetup/SfxSetup.c | 14 +- C/XzDec.c | 47 +- CPP/7zip/Archive/7z/7zIn.cpp | 101 ++- CPP/7zip/Archive/7z/7zUpdate.cpp | 31 +- CPP/7zip/Archive/ApfsHandler.cpp | 4 +- CPP/7zip/Archive/ExtHandler.cpp | 36 +- CPP/7zip/Archive/HfsHandler.cpp | 4 +- CPP/7zip/Archive/LpHandler.cpp | 14 +- CPP/7zip/Archive/LvmHandler.cpp | 3 +- CPP/7zip/Archive/MbrHandler.cpp | 7 +- CPP/7zip/Archive/Nsis/NsisIn.cpp | 6 +- CPP/7zip/Archive/NtfsHandler.cpp | 8 +- CPP/7zip/Archive/PeHandler.cpp | 24 +- CPP/7zip/Archive/SparseHandler.cpp | 4 +- CPP/7zip/Archive/SquashfsHandler.cpp | 7 +- CPP/7zip/Archive/Wim/WimHandlerOut.cpp | 8 +- CPP/7zip/Archive/Wim/WimIn.cpp | 3 + CPP/7zip/Archive/Wim/WimIn.h | 19 +- CPP/7zip/Common/CreateCoder.cpp | 2 +- CPP/7zip/Common/MethodProps.h | 3 +- CPP/7zip/Common/PropId.cpp | 4 +- CPP/7zip/Compress/CodecExports.cpp | 2 +- CPP/7zip/UI/Agent/AgentOut.cpp | 1 + CPP/7zip/UI/Agent/AgentProxy.cpp | 48 +- CPP/7zip/UI/Agent/AgentProxy.h | 44 +- CPP/7zip/UI/Common/ArchiveExtractCallback.cpp | 6 + CPP/7zip/UI/Common/LoadCodecs.cpp | 9 +- CPP/7zip/UI/Common/UpdatePair.cpp | 1 + CPP/7zip/UI/Common/UpdatePair.h | 2 +- CPP/7zip/UI/Common/UpdateProduce.cpp | 1 + CPP/7zip/UI/Common/UpdateProduce.h | 28 +- CPP/7zip/UI/Far/FarUtils.cpp | 15 +- CPP/7zip/UI/Far/Plugin.cpp | 15 +- CPP/7zip/UI/FileManager/BrowseDialog2.cpp | 25 +- CPP/Common/Common0.h | 2 +- CPP/Windows/Clipboard.cpp | 2 +- CPP/Windows/CommonDialog.cpp | 2 +- CPP/Windows/Console.h | 2 +- CPP/Windows/Control/ImageList.h | 2 +- CPP/Windows/FileFind.h | 2 - CPP/Windows/FileIO.h | 2 +- CPP/Windows/FileSystem.cpp | 2 +- CPP/Windows/Menu.h | 2 +- CPP/Windows/ProcessUtils.h | 2 +- CPP/Windows/PropVariantConv.cpp | 2 +- CPP/Windows/SecurityUtils.h | 2 +- CPP/Windows/Shell.h | 2 +- CPP/Windows/Synchronization.h | 2 +- CPP/Windows/Thread.h | 2 +- CPP/Windows/TimeUtils.cpp | 2 +- CPP/Windows/{Defs.h => WinDefs.h} | 4 +- CPP/Windows/Window.h | 2 +- DOC/7zip.wxs | 2 +- DOC/readme.txt | 2 +- DOC/src-history.txt | 5 + 63 files changed, 730 insertions(+), 640 deletions(-) rename CPP/Windows/{Defs.h => WinDefs.h} (83%) diff --git a/C/7zArcIn.c b/C/7zArcIn.c index 4dc3ba1..f6f6e7c 100644 --- a/C/7zArcIn.c +++ b/C/7zArcIn.c @@ -11,7 +11,7 @@ #include "CpuArch.h" #define MY_ALLOC(T, p, size, alloc) \ - { if ((p = (T *)ISzAlloc_Alloc(alloc, (size) * sizeof(T))) == NULL) return SZ_ERROR_MEM; } + { if ((p = (T *)ISzAlloc_Alloc(alloc, (size_t)(size) * sizeof(T))) == NULL) return SZ_ERROR_MEM; } #define MY_ALLOC_ZE(T, p, size, alloc) \ { if ((size) == 0) p = NULL; else MY_ALLOC(T, p, size, alloc) } @@ -22,8 +22,6 @@ #define MY_ALLOC_ZE_AND_CPY(to, size, from, alloc) \ { if ((size) == 0) to = NULL; else { MY_ALLOC_AND_CPY(to, size, from, alloc) } } -#define k7zMajorVersion 0 - enum EIdEnum { k7zIdEnd, @@ -52,15 +50,13 @@ enum EIdEnum k7zIdEncodedHeader, k7zIdStartPos, k7zIdDummy - // k7zNtSecure, - // k7zParent, - // k7zIsReal }; const Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; #define SzBitUi32s_INIT(p) { (p)->Defs = NULL; (p)->Vals = NULL; } +Z7_FORCE_INLINE static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAllocPtr alloc) { if (num == 0) @@ -76,6 +72,7 @@ static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAllocPtr alloc) return SZ_OK; } +Z7_FORCE_INLINE static void SzBitUi32s_Free(CSzBitUi32s *p, ISzAllocPtr alloc) { ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL; @@ -84,13 +81,14 @@ static void SzBitUi32s_Free(CSzBitUi32s *p, ISzAllocPtr alloc) #define SzBitUi64s_INIT(p) { (p)->Defs = NULL; (p)->Vals = NULL; } +Z7_FORCE_INLINE static void SzBitUi64s_Free(CSzBitUi64s *p, ISzAllocPtr alloc) { ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL; ISzAlloc_Free(alloc, p->Vals); p->Vals = NULL; } - +Z7_NO_INLINE static void SzAr_Init(CSzAr *p) { p->NumPackStreams = 0; @@ -110,23 +108,22 @@ static void SzAr_Init(CSzAr *p) p->RangeLimit = 0; } +Z7_NO_INLINE static void SzAr_Free(CSzAr *p, ISzAllocPtr alloc) { ISzAlloc_Free(alloc, p->PackPositions); SzBitUi32s_Free(&p->FolderCRCs, alloc); - ISzAlloc_Free(alloc, p->FoCodersOffsets); ISzAlloc_Free(alloc, p->FoStartPackStreamIndex); ISzAlloc_Free(alloc, p->FoToCoderUnpackSizes); ISzAlloc_Free(alloc, p->FoToMainUnpackSizeIndex); ISzAlloc_Free(alloc, p->CoderUnpackSizes); - ISzAlloc_Free(alloc, p->CodersData); SzAr_Init(p); } - +Z7_NO_INLINE void SzArEx_Init(CSzArEx *p) { SzAr_Init(&p->db); @@ -150,6 +147,7 @@ void SzArEx_Init(CSzArEx *p) SzBitUi64s_INIT(&p->CTime) } +Z7_NO_INLINE void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc) { ISzAlloc_Free(alloc, p->UnpackPositions); @@ -172,15 +170,6 @@ void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc) } -static int TestSignatureCandidate(const Byte *testBytes) -{ - unsigned i; - for (i = 0; i < k7zSignatureSize; i++) - if (testBytes[i] != k7zSignature[i]) - return 0; - return 1; -} - #define SzData_CLEAR(p) { (p)->Data = NULL; (p)->Size = 0; } #define SZ_READ_BYTE_SD_NOCHECK(_sd_, dest) \ @@ -199,14 +188,9 @@ static int TestSignatureCandidate(const Byte *testBytes) #define SKIP_DATA(sd, size) { sd->Size -= (size_t)(size); sd->Data += (size_t)(size); } #define SKIP_DATA2(sd, size) { sd.Size -= (size_t)(size); sd.Data += (size_t)(size); } -#define SZ_READ_32(dest) if (sd.Size < 4) return SZ_ERROR_ARCHIVE; \ - dest = GetUi32(sd.Data); SKIP_DATA2(sd, 4); - static Z7_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value) { - Byte firstByte, mask; - unsigned i; - UInt32 v; + unsigned firstByte, mask, i, v; SZ_READ_BYTE(firstByte) if ((firstByte & 0x80) == 0) @@ -223,18 +207,18 @@ static Z7_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value) SZ_READ_BYTE(mask) *value = v | ((UInt32)mask << 8); mask = 0x20; - for (i = 2; i < 8; i++) + for (i = 2 * 8; i < 8 * 8; i += 8) { - Byte b; + unsigned b; if ((firstByte & mask) == 0) { const UInt64 highPart = (unsigned)firstByte & (unsigned)(mask - 1); - *value |= (highPart << (8 * i)); + *value |= (highPart << i); return SZ_OK; } - SZ_READ_BYTE(b) - *value |= ((UInt64)b << (8 * i)); mask >>= 1; + SZ_READ_BYTE(b) + *value |= ((UInt64)b << i); } return SZ_OK; } @@ -242,7 +226,7 @@ static Z7_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value) static Z7_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value) { - Byte firstByte; + unsigned firstByte; UInt64 value64; if (sd->Size == 0) return SZ_ERROR_ARCHIVE; @@ -265,6 +249,7 @@ static Z7_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value) #define ReadID(sd, value) ReadNumber(sd, value) +Z7_NO_INLINE static SRes SkipData(CSzData *sd) { UInt64 size; @@ -275,6 +260,7 @@ static SRes SkipData(CSzData *sd) return SZ_OK; } +Z7_NO_INLINE static SRes WaitId(CSzData *sd, UInt32 id) { for (;;) @@ -289,16 +275,8 @@ static SRes WaitId(CSzData *sd, UInt32 id) } } -static SRes RememberBitVector(CSzData *sd, size_t numItems, const Byte **v) -{ - const size_t numBytes = (numItems + 7) >> 3; - if (numBytes > sd->Size) - return SZ_ERROR_ARCHIVE; - *v = sd->Data; - SKIP_DATA(sd, numBytes) - return SZ_OK; -} +Z7_NO_INLINE static UInt32 CountDefinedBits(const Byte *bits, UInt32 numItems) { unsigned b = 0; @@ -339,8 +317,8 @@ static Z7_NO_INLINE SRes ReadBitVector(CSzData *sd, size_t numItems, Byte **v, I memset(v2, 0xFF, (size_t)numBytes); { const unsigned numBits = (unsigned)numItems & 7; - if (numBits != 0) - v2[(size_t)numBytes - 1] = (Byte)((((UInt32)1 << numBits) - 1) << (8 - numBits)); + if (numBits) + v2[(size_t)numBytes - 1] = (Byte)(0xff00u >> numBits); } return SZ_OK; } @@ -348,31 +326,40 @@ static Z7_NO_INLINE SRes ReadBitVector(CSzData *sd, size_t numItems, Byte **v, I static Z7_NO_INLINE SRes ReadUi32s(CSzData *sd2, size_t numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) { size_t i; - CSzData sd; + const Byte *data; + size_t size; UInt32 *vals; const Byte *defs; - MY_ALLOC_ZE(UInt32, crcs->Vals, numItems, alloc) - sd = *sd2; + MY_ALLOC_ZE(UInt32, vals, numItems, alloc) + crcs->Vals = vals; defs = crcs->Defs; - vals = crcs->Vals; + data = sd2->Data; + size = sd2->Size; for (i = 0; i < numItems; i++) if (SzBitArray_Check(defs, i)) { - SZ_READ_32(vals[i]) + if (size < 4) + return SZ_ERROR_ARCHIVE; + size -= 4; + vals[i] = GetUi32(data); + data += 4; } else vals[i] = 0; - *sd2 = sd; + sd2->Data = data; + sd2->Size = size; return SZ_OK; } static SRes ReadBitUi32s(CSzData *sd, size_t numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) { - SzBitUi32s_Free(crcs, alloc); + if (crcs->Defs) + return SZ_ERROR_ARCHIVE; RINOK(ReadBitVector(sd, numItems, &crcs->Defs, alloc)) return ReadUi32s(sd, numItems, crcs, alloc); } +Z7_NO_INLINE static SRes SkipBitUi32s(CSzData *sd, UInt32 numItems) { Byte allAreDefined; @@ -395,25 +382,26 @@ static SRes SkipBitUi32s(CSzData *sd, UInt32 numItems) static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAllocPtr alloc) { RINOK(SzReadNumber32(sd, &p->NumPackStreams)) - RINOK(WaitId(sd, k7zIdSize)) - MY_ALLOC(UInt64, p->PackPositions, (size_t)p->NumPackStreams + 1, alloc) { - UInt64 sum = 0; - UInt32 i; - const UInt32 numPackStreams = p->NumPackStreams; - for (i = 0; i < numPackStreams; i++) + UInt64 *packPositions; + UInt64 sum; + size_t num = (size_t)p->NumPackStreams + 1; + MY_ALLOC(UInt64, packPositions, num, alloc) + p->PackPositions = packPositions; + sum = 0; + for (;;) { UInt64 packSize; - p->PackPositions[i] = sum; + *packPositions++ = sum; + if (--num == 0) + break; RINOK(ReadNumber(sd, &packSize)) sum += packSize; if (sum < packSize) return SZ_ERROR_ARCHIVE; } - p->PackPositions[i] = sum; } - for (;;) { UInt64 type; @@ -430,85 +418,79 @@ static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAllocPtr alloc) } } -/* -static SRes SzReadSwitch(CSzData *sd) -{ - Byte external; - RINOK(SzReadByte(sd, &external)); - return (external == 0) ? SZ_OK: SZ_ERROR_UNSUPPORTED; -} -*/ #define k_NumCodersStreams_in_Folder_MAX (SZ_NUM_BONDS_IN_FOLDER_MAX + SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX) SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) { - UInt32 numCoders, i; - UInt32 numInStreams = 0; - const Byte *dataStart = sd->Data; + UInt32 numCoders, i, numInStreams = 0; + const Byte * const dataStart = sd->Data; - f->NumCoders = 0; - f->NumBonds = 0; - f->NumPackStreams = 0; + // f->NumCoders = 0; + // f->NumBonds = 0; + // f->NumPackStreams = 0; f->UnpackStream = 0; RINOK(SzReadNumber32(sd, &numCoders)) if (numCoders == 0 || numCoders > SZ_NUM_CODERS_IN_FOLDER_MAX) return SZ_ERROR_UNSUPPORTED; + f->NumCoders = numCoders; for (i = 0; i < numCoders; i++) { Byte mainByte; - CSzCoderInfo *coder = f->Coders + i; - unsigned idSize, j; - UInt64 id; - - SZ_READ_BYTE(mainByte) - if ((mainByte & 0xC0) != 0) - return SZ_ERROR_UNSUPPORTED; - - idSize = (unsigned)(mainByte & 0xF); - if (idSize > sizeof(id)) - return SZ_ERROR_UNSUPPORTED; - if (idSize > sd->Size) - return SZ_ERROR_ARCHIVE; - id = 0; - for (j = 0; j < idSize; j++) + CSzCoderInfo *coder; { - id = ((id << 8) | *sd->Data); - sd->Data++; + unsigned idSize, j; + UInt64 id; + const Byte *data; + + if (!sd->Size) + return SZ_ERROR_ARCHIVE; sd->Size--; + data = sd->Data; + mainByte = *data++; + if (mainByte & 0xC0) + return SZ_ERROR_UNSUPPORTED; + idSize = mainByte & 0xF; + if (idSize > sizeof(id)) + return SZ_ERROR_UNSUPPORTED; + if (idSize > sd->Size) + return SZ_ERROR_ARCHIVE; + sd->Size -= idSize; + id = 0; + for (j = 0; j < idSize; j++) + id = (id << 8) | *data++; + sd->Data = data; + if (id > (UInt32)0xFFFFFFFF) + return SZ_ERROR_UNSUPPORTED; + coder = f->Coders + i; + coder->MethodID = (UInt32)id; } - if (id > (UInt32)0xFFFFFFFF) - return SZ_ERROR_UNSUPPORTED; - coder->MethodID = (UInt32)id; coder->NumStreams = 1; coder->PropsOffset = 0; coder->PropsSize = 0; - if ((mainByte & 0x10) != 0) + if (mainByte & 0x10) { UInt32 numStreams; - RINOK(SzReadNumber32(sd, &numStreams)) if (numStreams > k_NumCodersStreams_in_Folder_MAX) return SZ_ERROR_UNSUPPORTED; coder->NumStreams = (Byte)numStreams; - RINOK(SzReadNumber32(sd, &numStreams)) if (numStreams != 1) return SZ_ERROR_UNSUPPORTED; } numInStreams += coder->NumStreams; - if (numInStreams > k_NumCodersStreams_in_Folder_MAX) return SZ_ERROR_UNSUPPORTED; - if ((mainByte & 0x20) != 0) + if (mainByte & 0x20) { - UInt32 propsSize = 0; + UInt32 propsSize; RINOK(SzReadNumber32(sd, &propsSize)) if (propsSize > sd->Size) return SZ_ERROR_ARCHIVE; @@ -521,14 +503,6 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) } } - /* - if (numInStreams == 1 && numCoders == 1) - { - f->NumPackStreams = 1; - f->PackStreams[0] = 0; - } - else - */ { Byte streamUsed[k_NumCodersStreams_in_Folder_MAX]; UInt32 numBonds, numPackStreams; @@ -545,14 +519,13 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) return SZ_ERROR_UNSUPPORTED; f->NumPackStreams = numPackStreams; - for (i = 0; i < numInStreams; i++) + for (i = 0; i < Z7_ARRAY_SIZE(streamUsed); i++) // numInStreams streamUsed[i] = False; - if (numBonds != 0) + if (numBonds) { Byte coderUsed[SZ_NUM_CODERS_IN_FOLDER_MAX]; - - for (i = 0; i < numCoders; i++) + for (i = 0; i < Z7_ARRAY_SIZE(coderUsed); i++) // numCoders coderUsed[i] = False; for (i = 0; i < numBonds; i++) @@ -570,24 +543,25 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) coderUsed[bp->OutIndex] = True; } - for (i = 0; i < numCoders; i++) + for (i = 0;;) + { if (!coderUsed[i]) - { - f->UnpackStream = i; break; - } - - if (i == numCoders) - return SZ_ERROR_ARCHIVE; + if (++i == numCoders) + return SZ_ERROR_ARCHIVE; + } + f->UnpackStream = i; } if (numPackStreams == 1) { - for (i = 0; i < numInStreams; i++) + for (i = 0;; i++) + { + if (i == numInStreams) + return SZ_ERROR_ARCHIVE; if (!streamUsed[i]) break; - if (i == numInStreams) - return SZ_ERROR_ARCHIVE; + } f->PackStreams[0] = i; } else @@ -601,40 +575,30 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) f->PackStreams[i] = index; } } - - f->NumCoders = numCoders; - return SZ_OK; } -static Z7_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num) +static SRes SkipNumbers(CSzData *sd2, UInt32 num) { - CSzData sd; - sd = *sd2; + const Byte *data = sd2->Data; + size_t size = sd2->Size; for (; num != 0; num--) { - Byte firstByte, mask; + unsigned firstByte; unsigned i; - SZ_READ_BYTE_2(firstByte) - if ((firstByte & 0x80) == 0) - continue; - if ((firstByte & 0x40) == 0) - { - if (sd.Size == 0) - return SZ_ERROR_ARCHIVE; - sd.Size--; - sd.Data++; - continue; - } - mask = 0x20; - for (i = 2; i < 8 && (firstByte & mask) != 0; i++) - mask >>= 1; - if (i > sd.Size) + if (size == 0) return SZ_ERROR_ARCHIVE; - SKIP_DATA2(sd, i) + firstByte = *data; + for (i = 1; firstByte & 0x80; i++) + firstByte <<= 1; + if (size < i) + return SZ_ERROR_ARCHIVE; + size -= i; + data += i; } - *sd2 = sd; + sd2->Data = data; + sd2->Size = size; return SZ_OK; } @@ -642,15 +606,10 @@ static Z7_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num) #define k_Scan_NumCoders_MAX 64 #define k_Scan_NumCodersStreams_in_Folder_MAX 64 - -static SRes ReadUnpackInfo(CSzAr *p, - CSzData *sd2, - UInt32 numFoldersMax, - const CBuf *tempBufs, UInt32 numTempBufs, - ISzAllocPtr alloc) +static SRes ReadUnpackInfo(CSzAr *p, CSzData *sd2, const UInt32 numFoldersMax, + const CBuf *tempBufs, UInt32 numTempBufs, ISzAllocPtr alloc) { CSzData sd; - UInt32 fo, numFolders, numCodersOutStreams, packStreamIndex; const Byte *startBufPtr; Byte external; @@ -742,15 +701,12 @@ static SRes ReadUnpackInfo(CSzAr *p, { Byte streamUsed[k_Scan_NumCodersStreams_in_Folder_MAX]; Byte coderUsed[k_Scan_NumCoders_MAX]; - UInt32 i; const UInt32 numBonds = numCoders - 1; if (numInStreams < numBonds) return SZ_ERROR_ARCHIVE; - if (numInStreams > k_Scan_NumCodersStreams_in_Folder_MAX) return SZ_ERROR_UNSUPPORTED; - for (i = 0; i < numInStreams; i++) streamUsed[i] = False; for (i = 0; i < numCoders; i++) @@ -782,16 +738,15 @@ static SRes ReadUnpackInfo(CSzAr *p, return SZ_ERROR_ARCHIVE; streamUsed[index] = True; } - - for (i = 0; i < numCoders; i++) + + for (i = 0;;) + { if (!coderUsed[i]) - { - indexOfMainStream = i; break; - } - - if (i == numCoders) - return SZ_ERROR_ARCHIVE; + if (++i == numCoders) + return SZ_ERROR_ARCHIVE; + } + indexOfMainStream = i; } p->FoStartPackStreamIndex[fo] = packStreamIndex; @@ -806,31 +761,38 @@ static SRes ReadUnpackInfo(CSzAr *p, } } + { + const size_t k_numCodersOutStreams_Limit = (size_t)1 << (sizeof(size_t) * 8 - 4); + if (numCodersOutStreams >= k_numCodersOutStreams_Limit) + return SZ_ERROR_UNSUPPORTED; + } p->FoToCoderUnpackSizes[fo] = numCodersOutStreams; - + p->FoStartPackStreamIndex[fo] = packStreamIndex; { const size_t dataSize = (size_t)(sd.Data - startBufPtr); - p->FoStartPackStreamIndex[fo] = packStreamIndex; p->FoCodersOffsets[fo] = dataSize; MY_ALLOC_ZE_AND_CPY(p->CodersData, dataSize, startBufPtr, alloc) } - if (external != 0) + if (external) { - if (sd.Size != 0) + if (sd.Size) return SZ_ERROR_ARCHIVE; sd = *sd2; } RINOK(WaitId(&sd, k7zIdCodersUnpackSize)) - - MY_ALLOC_ZE(UInt64, p->CoderUnpackSizes, (size_t)numCodersOutStreams, alloc) { - UInt32 i; - for (i = 0; i < numCodersOutStreams; i++) - { - RINOK(ReadNumber(&sd, p->CoderUnpackSizes + i)) - } + UInt64 *sizes; + MY_ALLOC_ZE(UInt64, sizes, (size_t)numCodersOutStreams, alloc) + p->CoderUnpackSizes = sizes; + if (numCodersOutStreams) + do + { + RINOK(ReadNumber(&sd, sizes)) + sizes++; + } + while (--numCodersOutStreams); } for (;;) @@ -838,10 +800,7 @@ static SRes ReadUnpackInfo(CSzAr *p, UInt64 type; RINOK(ReadID(&sd, &type)) if (type == k7zIdEnd) - { - *sd2 = sd; - return SZ_OK; - } + break; if (type == k7zIdCRC) { RINOK(ReadBitUi32s(&sd, numFolders, &p->FolderCRCs, alloc)) @@ -849,6 +808,8 @@ static SRes ReadUnpackInfo(CSzAr *p, } RINOK(SkipData(&sd)) } + *sd2 = sd; + return SZ_OK; } @@ -868,12 +829,12 @@ typedef struct } CSubStreamInfo; -static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) +static SRes ReadSubStreamsInfo(const CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) { UInt64 type = 0; - UInt32 numSubDigests = 0; const UInt32 numFolders = p->NumFolders; UInt32 numUnpackStreams = numFolders; + UInt32 numSubDigests = numFolders; UInt32 numUnpackSizesInData = 0; for (;;) @@ -882,6 +843,8 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) if (type == k7zIdNumUnpackStream) { UInt32 i; + if (ssi->sdNumSubStreams.Data) + return SZ_ERROR_UNSUPPORTED; ssi->sdNumSubStreams.Data = sd->Data; numUnpackStreams = 0; numSubDigests = 0; @@ -889,10 +852,10 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) { UInt32 numStreams; RINOK(SzReadNumber32(sd, &numStreams)) - if (numUnpackStreams > numUnpackStreams + numStreams) - return SZ_ERROR_UNSUPPORTED; numUnpackStreams += numStreams; - if (numStreams != 0) + if (numUnpackStreams < numStreams) + return SZ_ERROR_UNSUPPORTED; + if (numStreams) numUnpackSizesInData += (numStreams - 1); if (numStreams != 1 || !SzBitWithVals_Check(&p->FolderCRCs, i)) numSubDigests += numStreams; @@ -905,12 +868,8 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) RINOK(SkipData(sd)) } - if (!ssi->sdNumSubStreams.Data) - { - numSubDigests = numFolders; - if (p->FolderCRCs.Defs) - numSubDigests = numFolders - CountDefinedBits(p->FolderCRCs.Defs, numFolders); - } + if (!ssi->sdNumSubStreams.Data && p->FolderCRCs.Defs) + numSubDigests = numFolders - CountDefinedBits(p->FolderCRCs.Defs, numFolders); ssi->NumTotalSubStreams = numUnpackStreams; ssi->NumSubDigests = numSubDigests; @@ -929,6 +888,8 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) return SZ_OK; if (type == k7zIdCRC) { + if (ssi->sdCRCs.Data) + return SZ_ERROR_UNSUPPORTED; ssi->sdCRCs.Data = sd->Data; RINOK(SkipBitUi32s(sd, numSubDigests)) ssi->sdCRCs.Size = (size_t)(sd->Data - ssi->sdCRCs.Data); @@ -941,9 +902,11 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) } } + static SRes SzReadStreamsInfo(CSzAr *p, CSzData *sd, - UInt32 numFoldersMax, const CBuf *tempBufs, UInt32 numTempBufs, + const UInt32 numFoldersMax, + const CBuf * const tempBufs, const UInt32 numTempBufs, UInt64 *dataOffset, CSubStreamInfo *ssi, ISzAllocPtr alloc) @@ -985,12 +948,13 @@ static SRes SzReadStreamsInfo(CSzAr *p, return (type == k7zIdEnd ? SZ_OK : SZ_ERROR_UNSUPPORTED); } + static SRes SzReadAndDecodePackedStreams( ILookInStreamPtr inStream, CSzData *sd, - CBuf *tempBufs, - UInt32 numFoldersMax, - UInt64 baseOffset, + CBuf * const tempBufs, + const UInt32 numFoldersMax, + const UInt64 baseOffset, CSzAr *p, ISzAllocPtr allocTemp) { @@ -1027,6 +991,7 @@ static SRes SzReadAndDecodePackedStreams( return SZ_OK; } + // (size & 1) == 0 // (data) is aligned for 2-bytes static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size_t *offsets) @@ -1053,30 +1018,35 @@ static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size return (p == lim) ? SZ_OK : SZ_ERROR_ARCHIVE; } -static Z7_NO_INLINE SRes ReadTime(CSzBitUi64s *p, size_t num, - CSzData *sd2, - const CBuf *tempBufs, UInt32 numTempBufs, - ISzAllocPtr alloc) + +static SRes ReadTime(CSzBitUi64s *p, size_t num, CSzData *sd2, + const CBuf *tempBufs, UInt32 numTempBufs, ISzAllocPtr alloc) { - CSzData sd; + const Byte *data; + size_t size; size_t i; CNtfsFileTime *vals; Byte *defs; Byte external; + if (p->Defs) + return SZ_ERROR_ARCHIVE; RINOK(ReadBitVector(sd2, num, &p->Defs, alloc)) SZ_READ_BYTE_SD(sd2, external) if (external == 0) - sd = *sd2; + { + data = sd2->Data; + size = sd2->Size; + } else { UInt32 index; RINOK(SzReadNumber32(sd2, &index)) - if (index >= numTempBufs) + if (index >= numTempBufs || sd2->Size) return SZ_ERROR_ARCHIVE; - sd.Data = tempBufs[index].data; - sd.Size = tempBufs[index].size; + data = tempBufs[index].data; + size = tempBufs[index].size; } MY_ALLOC_ZE(CNtfsFileTime, p->Vals, num, alloc) @@ -1085,18 +1055,18 @@ static Z7_NO_INLINE SRes ReadTime(CSzBitUi64s *p, size_t num, for (i = 0; i < num; i++) if (SzBitArray_Check(defs, i)) { - if (sd.Size < 8) + if (size < 8) return SZ_ERROR_ARCHIVE; - vals[i].Low = GetUi32(sd.Data); - vals[i].High = GetUi32(sd.Data + 4); - SKIP_DATA2(sd, 8) + size -= 8; + vals[i].Low = GetUi32(data); + vals[i].High = GetUi32(data + 4); + data += 8; } else vals[i].High = vals[i].Low = 0; - if (external == 0) - *sd2 = sd; - + if (size) + return SZ_ERROR_ARCHIVE; return SZ_OK; } @@ -1104,16 +1074,11 @@ static Z7_NO_INLINE SRes ReadTime(CSzBitUi64s *p, size_t num, #define NUM_ADDITIONAL_STREAMS_MAX 8 -static SRes SzReadHeader2( - CSzArEx *p, /* allocMain */ - CSzData *sd, - ILookInStreamPtr inStream, - CBuf *tempBufs, UInt32 *numTempBufs, - ISzAllocPtr allocMain, - ISzAllocPtr allocTemp - ) +static SRes SzReadHeader2(CSzArEx *p, CSzData *sd, ILookInStreamPtr inStream, + CBuf * const tempBufs, ISzAllocPtr allocMain, ISzAllocPtr allocTemp) { CSubStreamInfo ssi; + UInt32 numTempBufs = 0; { UInt64 type; @@ -1150,7 +1115,7 @@ static SRes SzReadHeader2( res = SzReadAndDecodePackedStreams(inStream, sd, tempBufs, NUM_ADDITIONAL_STREAMS_MAX, p->startPosAfterHeader, &tempAr, allocTemp); - *numTempBufs = tempAr.NumFolders; + numTempBufs = tempAr.NumFolders; SzAr_Free(&tempAr, allocTemp); if (res != SZ_OK) @@ -1160,24 +1125,21 @@ static SRes SzReadHeader2( if (type == k7zIdMainStreamsInfo) { - RINOK(SzReadStreamsInfo(&p->db, sd, (UInt32)1 << 30, tempBufs, *numTempBufs, + static const UInt32 k_numFoldersMax = (UInt32)1 << 30; + RINOK(SzReadStreamsInfo(&p->db, sd, k_numFoldersMax, tempBufs, numTempBufs, &p->dataPos, &ssi, allocMain)) p->dataPos += p->startPosAfterHeader; RINOK(ReadID(sd, &type)) } if (type == k7zIdEnd) - { return SZ_OK; - } - if (type != k7zIdFilesInfo) return SZ_ERROR_ARCHIVE; } { - UInt32 numFiles = 0; - UInt32 numEmptyStreams = 0; + UInt32 numFiles, numEmptyStreams = 0; const Byte *emptyStreams = NULL; const Byte *emptyFiles = NULL; @@ -1186,44 +1148,68 @@ static SRes SzReadHeader2( for (;;) { + CSzData sdSwitch; UInt64 type; - UInt64 size; RINOK(ReadID(sd, &type)) if (type == k7zIdEnd) break; - RINOK(ReadNumber(sd, &size)) - if (size > sd->Size) - return SZ_ERROR_ARCHIVE; - - if (type >= ((UInt32)1 << 8)) { + UInt64 size; + RINOK(ReadNumber(sd, &size)) + if (size > sd->Size) + return SZ_ERROR_ARCHIVE; + sdSwitch.Data = sd->Data; + sdSwitch.Size = (size_t)size; SKIP_DATA(sd, size) } - else switch ((unsigned)type) + if (type >= 64) + continue; + + switch ((unsigned)type) { + case k7zIdEmptyStream: + { + if (emptyStreams || emptyFiles) + return SZ_ERROR_ARCHIVE; + if ((numFiles + 7) >> 3 != sdSwitch.Size) + return SZ_ERROR_ARCHIVE; + emptyStreams = sdSwitch.Data; + numEmptyStreams = CountDefinedBits(emptyStreams, numFiles); + break; + } + + case k7zIdEmptyFile: + { + if (emptyFiles) + return SZ_ERROR_ARCHIVE; + if ((numEmptyStreams + 7) >> 3 != sdSwitch.Size) + return SZ_ERROR_ARCHIVE; + emptyFiles = sdSwitch.Data; + break; + } + case k7zIdName: { size_t namesSize; const Byte *namesData; Byte external; - - SZ_READ_BYTE(external) + if (p->FileNameOffsets) + return SZ_ERROR_ARCHIVE; + SZ_READ_BYTE_SD(&sdSwitch, external) if (external == 0) { - namesSize = (size_t)size - 1; - namesData = sd->Data; - SKIP_DATA(sd, namesSize) + namesData = sdSwitch.Data; + namesSize = sdSwitch.Size; } else { UInt32 index; - RINOK(SzReadNumber32(sd, &index)) - if (index >= *numTempBufs) + RINOK(SzReadNumber32(&sdSwitch, &index)) + if (index >= numTempBufs || sdSwitch.Size) return SZ_ERROR_ARCHIVE; - namesData = (tempBufs)[index].data; - namesSize = (tempBufs)[index].size; + namesData = tempBufs[index].data; + namesSize = tempBufs[index].size; } - if (namesSize & 1) return SZ_ERROR_ARCHIVE; MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain) @@ -1231,58 +1217,38 @@ static SRes SzReadHeader2( RINOK(SzReadFileNames(p->FileNames, namesSize, numFiles, p->FileNameOffsets)) break; } - case k7zIdEmptyStream: - { - RINOK(RememberBitVector(sd, numFiles, &emptyStreams)) - numEmptyStreams = CountDefinedBits(emptyStreams, numFiles); - emptyFiles = NULL; - break; - } - case k7zIdEmptyFile: - { - RINOK(RememberBitVector(sd, numEmptyStreams, &emptyFiles)) - break; - } + case k7zIdWinAttrib: { Byte external; - CSzData sdSwitch; - CSzData *sdPtr; - SzBitUi32s_Free(&p->Attribs, allocMain); - RINOK(ReadBitVector(sd, numFiles, &p->Attribs.Defs, allocMain)) - - SZ_READ_BYTE(external) - if (external == 0) - sdPtr = sd; - else + if (p->Attribs.Defs) + return SZ_ERROR_ARCHIVE; + RINOK(ReadBitVector(&sdSwitch, numFiles, &p->Attribs.Defs, allocMain)) + SZ_READ_BYTE_SD(&sdSwitch, external) + if (external) { UInt32 index; - RINOK(SzReadNumber32(sd, &index)) - if (index >= *numTempBufs) + RINOK(SzReadNumber32(&sdSwitch, &index)) + if (index >= numTempBufs || sdSwitch.Size) return SZ_ERROR_ARCHIVE; - sdSwitch.Data = (tempBufs)[index].data; - sdSwitch.Size = (tempBufs)[index].size; - sdPtr = &sdSwitch; + sdSwitch.Data = tempBufs[index].data; + sdSwitch.Size = tempBufs[index].size; } - RINOK(ReadUi32s(sdPtr, numFiles, &p->Attribs, allocMain)) + RINOK(ReadUi32s(&sdSwitch, numFiles, &p->Attribs, allocMain)) + if (sdSwitch.Size) + return SZ_ERROR_ARCHIVE; break; } - /* - case k7zParent: + + case k7zIdMTime: + case k7zIdCTime: { - SzBitUi32s_Free(&p->Parents, allocMain); - RINOK(ReadBitVector(sd, numFiles, &p->Parents.Defs, allocMain)); - RINOK(SzReadSwitch(sd)); - RINOK(ReadUi32s(sd, numFiles, &p->Parents, allocMain)); + RINOK(ReadTime((unsigned)type == k7zIdMTime ? &p->MTime: &p->CTime, + numFiles, &sdSwitch, tempBufs, numTempBufs, allocMain)) break; } - */ - case k7zIdMTime: RINOK(ReadTime(&p->MTime, numFiles, sd, tempBufs, *numTempBufs, allocMain)) break; - case k7zIdCTime: RINOK(ReadTime(&p->CTime, numFiles, sd, tempBufs, *numTempBufs, allocMain)) break; - default: - { - SKIP_DATA(sd, size) - } + + default: break; } } @@ -1481,25 +1447,19 @@ static SRes SzReadHeader( ISzAllocPtr allocTemp) { UInt32 i; - UInt32 numTempBufs = 0; SRes res; CBuf tempBufs[NUM_ADDITIONAL_STREAMS_MAX]; for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++) Buf_Init(tempBufs + i); - res = SzReadHeader2(p, sd, inStream, - tempBufs, &numTempBufs, - allocMain, allocTemp); + res = SzReadHeader2(p, sd, inStream, tempBufs, allocMain, allocTemp); for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++) Buf_Free(tempBufs + i, allocTemp); - RINOK(res) - - if (sd->Size != 0) - return SZ_ERROR_FAIL; - + if (res == SZ_OK && sd->Size != 0) + return SZ_ERROR_ARCHIVE; return res; } @@ -1510,53 +1470,52 @@ static SRes SzArEx_Open2( ISzAllocPtr allocTemp) { Byte header[k7zStartHeaderSize]; - Int64 startArcPos; + Int64 startPosAfterHeader; UInt64 nextHeaderOffset, nextHeaderSize; size_t nextHeaderSizeT; UInt32 nextHeaderCRC; CBuf buf; SRes res; - startArcPos = 0; - RINOK(ILookInStream_Seek(inStream, &startArcPos, SZ_SEEK_CUR)) - RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE)) - - if (!TestSignatureCandidate(header)) - return SZ_ERROR_NO_ARCHIVE; - if (header[6] != k7zMajorVersion) - return SZ_ERROR_UNSUPPORTED; + startPosAfterHeader = 0; // k7zStartHeaderSize + RINOK(ILookInStream_Seek(inStream, &startPosAfterHeader, SZ_SEEK_CUR)) + p->startPosAfterHeader = (UInt64)startPosAfterHeader; + { + unsigned i; + for (i = 0; i < k7zSignatureSize; i++) + if (header[i] != k7zSignature[i]) + return SZ_ERROR_NO_ARCHIVE; + if (header[6] != 0) // k7zMajorVersion + return SZ_ERROR_UNSUPPORTED; + } + if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) + return SZ_ERROR_CRC; nextHeaderOffset = GetUi64(header + 12); nextHeaderSize = GetUi64(header + 20); nextHeaderCRC = GetUi32(header + 28); - p->startPosAfterHeader = (UInt64)startArcPos + k7zStartHeaderSize; - - if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) - return SZ_ERROR_CRC; - p->db.RangeLimit = nextHeaderOffset; - + if (nextHeaderOffset >= (UInt64)1 << 62 || + nextHeaderSize >= (UInt64)1 << 48) + return SZ_ERROR_NO_ARCHIVE; nextHeaderSizeT = (size_t)nextHeaderSize; if (nextHeaderSizeT != nextHeaderSize) return SZ_ERROR_MEM; if (nextHeaderSizeT == 0) + { + if (nextHeaderOffset != 0 || nextHeaderCRC != 0) + return SZ_ERROR_NO_ARCHIVE; return SZ_OK; - if (nextHeaderOffset > nextHeaderOffset + nextHeaderSize || - nextHeaderOffset > nextHeaderOffset + nextHeaderSize + k7zStartHeaderSize) - return SZ_ERROR_NO_ARCHIVE; - + } { Int64 pos = 0; RINOK(ILookInStream_Seek(inStream, &pos, SZ_SEEK_END)) - if ((UInt64)pos < (UInt64)startArcPos + nextHeaderOffset || - (UInt64)pos < (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset || - (UInt64)pos < (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) + if ((UInt64)(pos - startPosAfterHeader) < nextHeaderOffset + nextHeaderSize) return SZ_ERROR_INPUT_EOF; } - - RINOK(LookInStream_SeekTo(inStream, (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset)) + RINOK(LookInStream_SeekTo(inStream, (UInt64)startPosAfterHeader + nextHeaderOffset)) if (!Buf_Create(&buf, nextHeaderSizeT, allocTemp)) return SZ_ERROR_MEM; @@ -1720,61 +1679,23 @@ SRes SzArEx_Extract( size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest) { - const size_t offs = p->FileNameOffsets[fileIndex]; - const size_t len = p->FileNameOffsets[fileIndex + 1] - offs; - if (dest != 0) + const size_t * const offsets = p->FileNameOffsets; + if (!offsets) { - size_t i; - const Byte *src = p->FileNames + offs * 2; - for (i = 0; i < len; i++) - dest[i] = GetUi16(src + i * 2); - } - return len; -} - -/* -size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex) -{ - size_t len; - if (!p->FileNameOffsets) + if (dest) + *dest = 0; return 1; - len = 0; - for (;;) + } { - UInt32 parent = (UInt32)(Int32)-1; - len += p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; - if SzBitWithVals_Check(&p->Parents, fileIndex) - parent = p->Parents.Vals[fileIndex]; - if (parent == (UInt32)(Int32)-1) - return len; - fileIndex = parent; + const size_t offs = offsets[fileIndex]; + const size_t len = offsets[fileIndex + 1] - offs; + if (dest) + { + size_t i; + const Byte *src = p->FileNames + offs * 2; + for (i = 0; i < len; i++) + dest[i] = GetUi16a(src + i * 2); + } + return len; } } - -UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest) -{ - BoolInt needSlash; - if (!p->FileNameOffsets) - { - *(--dest) = 0; - return dest; - } - needSlash = False; - for (;;) - { - UInt32 parent = (UInt32)(Int32)-1; - size_t curLen = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; - SzArEx_GetFileNameUtf16(p, fileIndex, dest - curLen); - if (needSlash) - *(dest - 1) = '/'; - needSlash = True; - dest -= curLen; - - if SzBitWithVals_Check(&p->Parents, fileIndex) - parent = p->Parents.Vals[fileIndex]; - if (parent == (UInt32)(Int32)-1) - return dest; - fileIndex = parent; - } -} -*/ diff --git a/C/7zVersion.h b/C/7zVersion.h index 387a91c..50ccebb 100644 --- a/C/7zVersion.h +++ b/C/7zVersion.h @@ -1,7 +1,7 @@ #define MY_VER_MAJOR 26 -#define MY_VER_MINOR 1 +#define MY_VER_MINOR 2 #define MY_VER_BUILD 0 -#define MY_VERSION_NUMBERS "26.01" +#define MY_VERSION_NUMBERS "26.02" #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-04-27" +#define MY_DATE "2026-06-25" #undef MY_COPYRIGHT #undef MY_VERSION_COPYRIGHT_DATE #define MY_AUTHOR_NAME "Igor Pavlov" diff --git a/C/Compiler.h b/C/Compiler.h index a3577b2..c06b883 100644 --- a/C/Compiler.h +++ b/C/Compiler.h @@ -76,6 +76,11 @@ #pragma GCC diagnostic ignored "-Wreserved-identifier" #endif +#if __clang_major__ >= 22 +// for "StdAfx.h" and "Precomp.h" +#pragma GCC diagnostic ignored "-Wshadow-header" +#endif + #endif // __clang__ #if defined(__clang__) && __clang_major__ >= 16 diff --git a/C/DllSecur.c b/C/DllSecur.c index bbbfc0a..d385259 100644 --- a/C/DllSecur.c +++ b/C/DllSecur.c @@ -1,5 +1,5 @@ /* DllSecur.c -- DLL loading security -2023-12-03 : Igor Pavlov : Public domain */ +: Igor Pavlov : Public domain */ #include "Precomp.h" @@ -67,7 +67,7 @@ void LoadSecurityDlls(void) // at Vista (ver 6.0) : CoCreateInstance(CLSID_ShellLink, ...) doesn't work after SetDefaultDllDirectories() : Check it ??? IF_NON_VISTA_SET_DLL_DIRS_AND_RETURN { - wchar_t buf[MAX_PATH + 100]; + WCHAR buf[MAX_PATH + 100]; const char *dll; unsigned pos = GetSystemDirectoryW(buf, MAX_PATH + 2); if (pos == 0 || pos > MAX_PATH) @@ -76,7 +76,7 @@ void LoadSecurityDlls(void) buf[pos++] = '\\'; for (dll = g_Dlls; *dll != 0;) { - wchar_t *dest = &buf[pos]; + WCHAR *dest = &buf[pos]; for (;;) { const char c = *dll++; diff --git a/C/MtDec.c b/C/MtDec.c index 96274b6..71fc1ee 100644 --- a/C/MtDec.c +++ b/C/MtDec.c @@ -1,5 +1,5 @@ /* MtDec.c -- Multi-thread Decoder -2024-02-20 : Igor Pavlov : Public domain */ +: Igor Pavlov : Public domain */ #include "Precomp.h" @@ -22,7 +22,7 @@ #define PRF(x) #endif -#define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d)) +#define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d);) void MtProgress_Init(CMtProgress *p, ICompressProgressPtr progress) { diff --git a/C/Util/7z/7zMain.c b/C/Util/7z/7zMain.c index 7048b66..300c363 100644 --- a/C/Util/7z/7zMain.c +++ b/C/Util/7z/7zMain.c @@ -960,7 +960,12 @@ int Z7_CDECL main(int numargs, char *args[]) if (listCommand == 0 && isDir && !fullPaths) continue; len = SzArEx_GetFileNameUtf16(&db, i, NULL); - // len = SzArEx_GetFullNameLen(&db, i); + + if (len > (1u << 20)) + { + res = SZ_ERROR_UNSUPPORTED; + break; + } if (len > tempSize) { diff --git a/C/Util/7zipInstall/7zipInstall.c b/C/Util/7zipInstall/7zipInstall.c index 7d8e8c4..ce30732 100644 --- a/C/Util/7zipInstall/7zipInstall.c +++ b/C/Util/7zipInstall/7zipInstall.c @@ -1,5 +1,5 @@ /* 7zipInstall.c - 7-Zip Installer -2024-04-05 : Igor Pavlov : Public domain */ +: Igor Pavlov : Public domain */ #include "Precomp.h" @@ -142,7 +142,7 @@ static WCHAR path[MAX_PATH * 2 + 40]; -static void CpyAscii(wchar_t *dest, const char *s) +static void CpyAscii(WCHAR *dest, const char *s) { for (;;) { @@ -153,13 +153,13 @@ static void CpyAscii(wchar_t *dest, const char *s) } } -static void CatAscii(wchar_t *dest, const char *s) +static void CatAscii(WCHAR *dest, const char *s) { dest += wcslen(dest); CpyAscii(dest, s); } -static void PrintErrorMessage(const char *s1, const wchar_t *s2) +static void PrintErrorMessage(const char *s1, const WCHAR *s2) { WCHAR m[MAX_PATH + 512]; m[0] = 0; @@ -196,7 +196,7 @@ static DWORD GetFileVersion(LPCWSTR s) if (!g_version_dll_hModule) { - wchar_t buf[MAX_PATH + 100]; + WCHAR buf[MAX_PATH + 100]; { unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2); if (len == 0 || len > MAX_PATH) @@ -255,13 +255,13 @@ static WRes MyCreateDir(LPCWSTR name) #define IS_LETTER_CHAR(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z')) #define IS_DRIVE_PATH(s) (IS_LETTER_CHAR(s[0]) && s[1] == ':' && IS_SEPAR(s[2])) -static int ReverseFind_PathSepar(const wchar_t *s) +static int ReverseFind_PathSepar(const WCHAR *s) { int separ = -1; int i; for (i = 0;; i++) { - wchar_t c = s[i]; + WCHAR c = s[i]; if (c == 0) return separ; if (IS_SEPAR(c)) @@ -566,7 +566,7 @@ static void NormalizePrefix(WCHAR *s) for (;; i++) { - const wchar_t c = s[i]; + const WCHAR c = s[i]; if (c == 0) break; if (c == '/') @@ -587,10 +587,10 @@ static char MyCharLower_Ascii(char c) return c; } -static wchar_t MyWCharLower_Ascii(wchar_t c) +static WCHAR MyWCharLower_Ascii(WCHAR c) { if (c >= 'A' && c <= 'Z') - return (wchar_t)(c + 0x20); + return (WCHAR)(c + 0x20); return c; } @@ -976,13 +976,13 @@ static void WriteShellEx(void) } -static const wchar_t *GetCmdParam(const wchar_t *s) +static const WCHAR *GetCmdParam(const WCHAR *s) { unsigned pos = 0; BoolInt quoteMode = False; for (;; s++) { - wchar_t c = *s; + WCHAR c = *s; if (c == 0 || (c == L' ' && !quoteMode)) break; if (c == L'\"') @@ -999,12 +999,12 @@ static const wchar_t *GetCmdParam(const wchar_t *s) } -static void RemoveQuotes(wchar_t *s) +static void RemoveQuotes(WCHAR *s) { - const wchar_t *src = s; + const WCHAR *src = s; for (;;) { - wchar_t c = *src++; + WCHAR c = *src++; if (c == '\"') continue; *s++ = c; @@ -1039,7 +1039,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, CrcGenerateTable(); { - const wchar_t *s = GetCommandLineW(); + const WCHAR *s = GetCommandLineW(); #ifndef UNDER_CE s = GetCmdParam(s); @@ -1048,7 +1048,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, for (;;) { { - const wchar_t c = *s; + const WCHAR c = *s; if (c == 0) break; if (c == ' ') @@ -1059,7 +1059,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, } { - const wchar_t *s2 = GetCmdParam(s); + const WCHAR *s2 = GetCmdParam(s); BoolInt error = True; if (cmd[0] == '/') { @@ -1315,7 +1315,7 @@ if (res == SZ_OK) for (;;) { - const wchar_t c = path[i++]; + const WCHAR c = path[i++]; if (c == 0) break; if (c != ' ') diff --git a/C/Util/7zipUninstall/7zipUninstall.c b/C/Util/7zipUninstall/7zipUninstall.c index e7051e2..2c1333b 100644 --- a/C/Util/7zipUninstall/7zipUninstall.c +++ b/C/Util/7zipUninstall/7zipUninstall.c @@ -1,5 +1,5 @@ /* 7zipUninstall.c - 7-Zip Uninstaller -2024-03-21 : Igor Pavlov : Public domain */ +: Igor Pavlov : Public domain */ #include "Precomp.h" @@ -147,7 +147,7 @@ static LPCWSTR const kUninstallExe = L"Uninstall.exe"; #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))) -static void CpyAscii(wchar_t *dest, const char *s) +static void CpyAscii(WCHAR *dest, const char *s) { for (;;) { @@ -158,13 +158,13 @@ static void CpyAscii(wchar_t *dest, const char *s) } } -static void CatAscii(wchar_t *dest, const char *s) +static void CatAscii(WCHAR *dest, const char *s) { dest += wcslen(dest); CpyAscii(dest, s); } -static void PrintErrorMessage(const char *s1, const wchar_t *s2) +static void PrintErrorMessage(const char *s1, const WCHAR *s2) { WCHAR m[MAX_PATH + 512]; m[0] = 0; @@ -183,12 +183,12 @@ static void PrintErrorMessage(const char *s1, const wchar_t *s2) } -static BoolInt AreStringsEqual_NoCase(const wchar_t *s1, const wchar_t *s2) +static BoolInt AreStringsEqual_NoCase(const WCHAR *s1, const WCHAR *s2) { for (;;) { - wchar_t c1 = *s1++; - wchar_t c2 = *s2++; + WCHAR c1 = *s1++; + WCHAR c2 = *s2++; if (c1 != c2 && MAKE_CHAR_UPPER(c1) != MAKE_CHAR_UPPER(c2)) return False; if (c2 == 0) @@ -196,12 +196,12 @@ static BoolInt AreStringsEqual_NoCase(const wchar_t *s1, const wchar_t *s2) } } -static BoolInt IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_t *s2) +static BoolInt IsString1PrefixedByString2_NoCase(const WCHAR *s1, const WCHAR *s2) { for (;;) { - wchar_t c1; - const wchar_t c2 = *s2++; + WCHAR c1; + const WCHAR c2 = *s2++; if (c2 == 0) return True; c1 = *s1++; @@ -446,7 +446,7 @@ static LPCWSTR const k_AppPaths_7zFm = L"Software\\Microsoft\\Windows\\CurrentVe static LPCWSTR const k_Uninstall_7zip = k_REG_Uninstall L"7-Zip"; -static void RemoveQuotes(wchar_t *s) +static void RemoveQuotes(WCHAR *s) { const size_t len = wcslen(s); size_t i; @@ -457,7 +457,7 @@ static void RemoveQuotes(wchar_t *s) s[len - 2] = 0; } -static BoolInt AreEqual_Path_PrefixName(const wchar_t *s, const wchar_t *prefix, const wchar_t *name) +static BoolInt AreEqual_Path_PrefixName(const WCHAR *s, const WCHAR *prefix, const WCHAR *name) { if (!IsString1PrefixedByString2_NoCase(s, prefix)) return False; @@ -558,13 +558,13 @@ static void WriteCLSID(void) } -static const wchar_t *GetCmdParam(const wchar_t *s) +static const WCHAR *GetCmdParam(const WCHAR *s) { unsigned pos = 0; BoolInt quoteMode = False; for (;; s++) { - const wchar_t c = *s; + const WCHAR c = *s; if (c == 0 || (c == L' ' && !quoteMode)) break; if (c == L'\"') @@ -581,12 +581,12 @@ static const wchar_t *GetCmdParam(const wchar_t *s) } /* -static void RemoveQuotes(wchar_t *s) +static void RemoveQuotes(WCHAR *s) { - const wchar_t *src = s; + const WCHAR *src = s; for (;;) { - wchar_t c = *src++; + WCHAR c = *src++; if (c == '\"') continue; *s++ = c; @@ -618,11 +618,11 @@ static BOOL RemoveFileAfterReboot(void) // #define IS_LIMIT_CHAR(c) (c == 0 || c == ' ') -static BoolInt IsThereSpace(const wchar_t *s) +static BoolInt IsThereSpace(const WCHAR *s) { for (;;) { - const wchar_t c = *s++; + const WCHAR c = *s++; if (c == 0) return False; if (c == ' ') @@ -630,7 +630,7 @@ static BoolInt IsThereSpace(const wchar_t *s) } } -static void AddPathParam(wchar_t *dest, const wchar_t *src) +static void AddPathParam(WCHAR *dest, const WCHAR *src) { const BoolInt needQuote = IsThereSpace(src); if (needQuote) @@ -937,7 +937,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #endif lpCmdLine, int nCmdShow) { - const wchar_t *cmdParams; + const WCHAR *cmdParams; BoolInt useTemp = True; UNUSED_VAR(hPrevInstance) @@ -957,7 +957,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #endif { - const wchar_t *s = GetCommandLineW(); + const WCHAR *s = GetCommandLineW(); #ifndef UNDER_CE s = GetCmdParam(s); @@ -968,7 +968,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, for (;;) { { - wchar_t c = *s; + WCHAR c = *s; if (c == 0) break; if (c == ' ') @@ -979,7 +979,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, } { - const wchar_t *s2 = GetCmdParam(s); + const WCHAR *s2 = GetCmdParam(s); BoolInt error = True; if (cmd[0] == '/') { @@ -1022,7 +1022,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, } { - wchar_t *name; + WCHAR *name; const DWORD len = GetModuleFileNameW(NULL, modulePath, MAX_PATH); if (len == 0 || len > MAX_PATH) return 1; @@ -1031,10 +1031,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wcscpy(modulePrefix, modulePath); { - wchar_t *s = modulePrefix; + WCHAR *s = modulePrefix; for (;;) { - const wchar_t c = *s++; + const WCHAR c = *s++; if (c == 0) break; if (c == WCHAR_PATH_SEPARATOR) @@ -1079,14 +1079,14 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, CpyAscii(path + pathLen, "7z"); { - wchar_t *s = path + wcslen(path); + WCHAR *s = path + wcslen(path); UInt32 value = d; unsigned k; for (k = 0; k < 8; k++) { const unsigned t = value & 0xF; value >>= 4; - s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); + s[7 - k] = (WCHAR)((t < 10) ? ('0' + t) : ('A' + (t - 10))); } s[k] = 0; } diff --git a/C/Util/SfxSetup/SfxSetup.c b/C/Util/SfxSetup/SfxSetup.c index 9b5c1f9..344aa73 100644 --- a/C/Util/SfxSetup/SfxSetup.c +++ b/C/Util/SfxSetup/SfxSetup.c @@ -1,5 +1,5 @@ /* SfxSetup.c - 7z SFX Setup -2024-01-24 : Igor Pavlov : Public domain */ +: Igor Pavlov : Public domain */ #include "Precomp.h" @@ -54,7 +54,7 @@ static const char * const kNames[] = , "start" }; -static unsigned FindExt(const wchar_t *s, unsigned *extLen) +static unsigned FindExt(const WCHAR *s, unsigned *extLen) { unsigned len = (unsigned)wcslen(s); unsigned i; @@ -72,7 +72,7 @@ static unsigned FindExt(const wchar_t *s, unsigned *extLen) #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))) -static unsigned FindItem(const char * const *items, unsigned num, const wchar_t *s, unsigned len) +static unsigned FindItem(const char * const *items, unsigned num, const WCHAR *s, unsigned len) { unsigned i; for (i = 0; i < num; i++) @@ -268,7 +268,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #endif size_t pathLen; DWORD winRes; - const wchar_t *cmdLineParams; + const WCHAR *cmdLineParams; const char *errorMessage = NULL; BoolInt useShellExecute = True; DWORD exitCode = 0; @@ -306,7 +306,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, BoolInt quoteMode = False; for (;; cmdLineParams++) { - const wchar_t c = *cmdLineParams; + const WCHAR c = *cmdLineParams; if (c == L'\"') quoteMode = !quoteMode; else if (c == 0 || (c == L' ' && !quoteMode)) @@ -335,14 +335,14 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wcscpy(path + pathLen, L"7z"); { - wchar_t *s = path + wcslen(path); + WCHAR *s = path + wcslen(path); UInt32 value = d; unsigned k; for (k = 0; k < 8; k++) { const unsigned t = value & 0xF; value >>= 4; - s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); + s[7 - k] = (WCHAR)((t < 10) ? ('0' + t) : ('A' + (t - 10))); } s[k] = '\0'; } diff --git a/C/XzDec.c b/C/XzDec.c index fe6b425..e4ae144 100644 --- a/C/XzDec.c +++ b/C/XzDec.c @@ -25,8 +25,8 @@ #define PRF(x) #endif -#define PRF_STR(s) PRF(printf("\n" s "\n")) -#define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d)) +#define PRF_STR(s) PRF(printf("\n" s "\n");) +#define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d);) #include #include @@ -574,7 +574,7 @@ static SRes MixCoder_ResetFromMethod(CMixCoder *p, unsigned coderIndex, UInt64 m output (status) can be : CODER_STATUS_NOT_FINISHED CODER_STATUS_FINISHED_WITH_MARK - CODER_STATUS_NEEDS_MORE_INPUT - not implemented still + CODER_STATUS_NEEDS_MORE_INPUT */ static SRes MixCoder_Code(CMixCoder *p, @@ -582,8 +582,8 @@ static SRes MixCoder_Code(CMixCoder *p, const Byte *src, SizeT *srcLen, int srcWasFinished, ECoderFinishMode finishMode) { - SizeT destLenOrig = *destLen; - SizeT srcLenOrig = *srcLen; + const SizeT destLenOrig = *destLen; + const SizeT srcLenOrig = *srcLen; *destLen = 0; *srcLen = 0; @@ -597,39 +597,26 @@ static SRes MixCoder_Code(CMixCoder *p, if (p->outBuf) { SRes res; - SizeT destLen2, srcLen2; + SizeT destLen2; int wasFinished; PRF_STR("------- MixCoder Single ----------") - srcLen2 = srcLenOrig; destLen2 = destLenOrig; - + if (p->numCoders != 1) + { + if (destLen2 < p->outWritten) + return SZ_ERROR_FAIL; + destLen2 -= p->outWritten; + } + *srcLen = srcLenOrig; { IStateCoder *coder = &p->coders[0]; - res = coder->Code2(coder->p, NULL, &destLen2, src, &srcLen2, srcWasFinished, finishMode, - // &wasFinished, - &p->status); - wasFinished = (p->status == CODER_STATUS_FINISHED_WITH_MARK); + res = coder->Code2(coder->p, NULL, &destLen2, src, srcLen, srcWasFinished, finishMode, &p->status); } - p->res = res; - - /* - if (wasFinished) - p->status = CODER_STATUS_FINISHED_WITH_MARK; - else - { - if (res == SZ_OK) - if (destLen2 != destLenOrig) - p->status = CODER_STATUS_NEEDS_MORE_INPUT; - } - */ - - - *srcLen = srcLen2; - src += srcLen2; p->outWritten += destLen2; + wasFinished = (p->status == CODER_STATUS_FINISHED_WITH_MARK); if (res != SZ_OK || srcWasFinished || wasFinished) p->wasFinished = True; @@ -1016,8 +1003,8 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, int srcFinished, ECoderFinishMode finishMode, ECoderStatus *status) { - SizeT destLenOrig = *destLen; - SizeT srcLenOrig = *srcLen; + const SizeT destLenOrig = *destLen; + const SizeT srcLenOrig = *srcLen; *destLen = 0; *srcLen = 0; *status = CODER_STATUS_NOT_SPECIFIED; diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp index e2efc52..eb39478 100644 --- a/CPP/7zip/Archive/7z/7zIn.cpp +++ b/CPP/7zip/Archive/7z/7zIn.cpp @@ -698,22 +698,24 @@ void CInArchive::ReadPackInfo(CFolders &f) WaitId(NID::kSize); f.PackPositions.Alloc(numPackStreams + 1); + UInt64 * const packPositions = f.PackPositions; f.NumPackStreams = numPackStreams; UInt64 sum = 0; - for (CNum i = 0; i < numPackStreams; i++) + for (CNum i = 0;;) { - f.PackPositions[i] = sum; + packPositions[i] = sum; + if (i == numPackStreams) + break; + i++; const UInt64 packSize = ReadNumber(); sum += packSize; if (sum < packSize) ThrowIncorrect(); } - f.PackPositions[numPackStreams] = sum; - UInt64 type; for (;;) { - type = ReadID(); + const UInt64 type = ReadID(); if (type == NID::kEnd) return; if (type == NID::kCRC) @@ -857,19 +859,20 @@ void CInArchive::ReadUnpackInfo( StreamUsed[index] = true; } - for (i = 0; i < numCoders; i++) + for (i = 0;;) + { if (!CoderUsed[i]) - { - indexOfMainStream = i; break; - } - - if (i == numCoders) - ThrowUnsupported(); + if (++i == numCoders) + ThrowUnsupported(); + } + indexOfMainStream = i; } folders.FoToCoderUnpackSizes[fo] = numCodersOutStreams; numCodersOutStreams += numCoders; + if (numCodersOutStreams < numCoders) + ThrowUnsupported(); folders.FoStartPackStreamIndex[fo] = packStreamIndex; if (numPackStreams > folders.NumPackStreams - packStreamIndex) ThrowIncorrect(); @@ -880,7 +883,7 @@ void CInArchive::ReadUnpackInfo( const size_t dataSize = (size_t)(_inByteBack->GetPtr() - startBufPtr); folders.FoToCoderUnpackSizes[fo] = numCodersOutStreams; folders.FoStartPackStreamIndex[fo] = packStreamIndex; - folders.FoCodersDataOffset[fo] = (size_t)(_inByteBack->GetPtr() - startBufPtr); + folders.FoCodersDataOffset[fo] = dataSize; folders.CodersData.CopyFrom(startBufPtr, dataSize); // if (folders.NumPackStreams != packStreamIndex) ThrowUnsupported(); @@ -898,6 +901,8 @@ void CInArchive::ReadUnpackInfo( return; if (type == NID::kCRC) { + if (!folders.FolderCRCs.Defs.IsEmpty()) + ThrowIncorrect(); ReadHashDigests(numFolders, folders.FolderCRCs); continue; } @@ -911,19 +916,35 @@ void CInArchive::ReadSubStreamsInfo( CUInt32DefVector &digests) { folders.NumUnpackStreamsVector.Alloc(folders.NumFolders); - CNum i; - for (i = 0; i < folders.NumFolders; i++) - folders.NumUnpackStreamsVector[i] = 1; + bool NumUnpackStream_isFilled = false; UInt64 type; + + CNum numUnpackStreams = folders.NumFolders; for (;;) { type = ReadID(); if (type == NID::kNumUnpackStream) { - for (i = 0; i < folders.NumFolders; i++) - folders.NumUnpackStreamsVector[i] = ReadNum(); + if (NumUnpackStream_isFilled) + ThrowIncorrect(); + NumUnpackStream_isFilled = true; + CNum numFolders = folders.NumFolders; + numUnpackStreams = 0; + if (numFolders) + { + UInt32 *dest = folders.NumUnpackStreamsVector.NonConstData(); + do + { + const CNum num = ReadNum(); + *dest++ = num; + numUnpackStreams += num; + if (numUnpackStreams < num) + ThrowUnsupported(); + } + while (--numFolders); + } continue; } if (type == NID::kCRC || type == NID::kSize || type == NID::kEnd) @@ -931,6 +952,20 @@ void CInArchive::ReadSubStreamsInfo( SkipData(); } + if (!NumUnpackStream_isFilled) + { + CNum numFolders = folders.NumFolders; + if (numFolders) + { + UInt32 *dest = folders.NumUnpackStreamsVector.NonConstData(); + do + *dest++ = 1; + while (--numFolders); + } + } + + unpackSizes.ClearAndReserve(numUnpackStreams); + CNum i; if (type == NID::kSize) { for (i = 0; i < folders.NumFolders; i++) @@ -943,16 +978,20 @@ void CInArchive::ReadSubStreamsInfo( UInt64 sum = 0; for (CNum j = 1; j < numSubstreams; j++) { + if (unpackSizes.Size() >= numUnpackStreams) + ThrowIncorrect(); // internal failure const UInt64 size = ReadNumber(); - unpackSizes.Add(size); + unpackSizes.AddInReserved(size); sum += size; if (sum < size) ThrowIncorrect(); } + if (unpackSizes.Size() >= numUnpackStreams) + ThrowIncorrect(); // internal failure const UInt64 folderUnpackSize = folders.GetFolderUnpackSize(i); if (folderUnpackSize < sum) ThrowIncorrect(); - unpackSizes.Add(folderUnpackSize - sum); + unpackSizes.AddInReserved(folderUnpackSize - sum); } type = ReadID(); } @@ -966,10 +1005,17 @@ void CInArchive::ReadSubStreamsInfo( if (val > 1) ThrowIncorrect(); if (val == 1) - unpackSizes.Add(folders.GetFolderUnpackSize(i)); + { + if (unpackSizes.Size() >= numUnpackStreams) + ThrowIncorrect(); // internal failure + unpackSizes.AddInReserved(folders.GetFolderUnpackSize(i)); + } } } + if (unpackSizes.Size() != numUnpackStreams) + ThrowIncorrect(); + unsigned numDigests = 0; for (i = 0; i < folders.NumFolders; i++) { @@ -984,6 +1030,8 @@ void CInArchive::ReadSubStreamsInfo( break; if (type == NID::kCRC) { + if (!digests.Defs.IsEmpty()) + ThrowIncorrect(); // CUInt32DefVector digests2; // ReadHashDigests(numDigests, digests2); CBoolVector digests2; @@ -1092,10 +1140,13 @@ void CInArchive::ReadStreamsInfo( So we don't need to fill digests with values. */ // digests.Vals.ClearAndSetSize(folders.NumFolders); // BoolVector_Fill_False(digests.Defs, folders.NumFolders); + unpackSizes.ClearAndSetSize(folders.NumFolders); + UInt64 * const unpackSizes2 = unpackSizes.NonConstData(); + CNum * const numUnpackStreamsVector2 = folders.NumUnpackStreamsVector; for (CNum i = 0; i < folders.NumFolders; i++) { - folders.NumUnpackStreamsVector[i] = 1; - unpackSizes.Add(folders.GetFolderUnpackSize(i)); + numUnpackStreamsVector2[i] = 1; + unpackSizes2[i] = folders.GetFolderUnpackSize(i); // digests.Vals[i] = 0; } } @@ -1648,8 +1699,8 @@ HRESULT CInArchive::ReadDatabase2( db.PhySize = kHeaderSize; db.IsArc = false; - if ((Int64)nextHeaderOffset < 0 || - nextHeaderSize > ((UInt64)1 << 62)) + if (nextHeaderOffset >= (UInt64)1 << 62 || + nextHeaderSize > ((UInt64)1 << 48)) return S_FALSE; HeadersSize = kHeaderSize; diff --git a/CPP/7zip/Archive/7z/7zUpdate.cpp b/CPP/7zip/Archive/7z/7zUpdate.cpp index 6ba04a2..b05d3cf 100644 --- a/CPP/7zip/Archive/7z/7zUpdate.cpp +++ b/CPP/7zip/Archive/7z/7zUpdate.cpp @@ -36,13 +36,6 @@ struct CFilterMode UInt32 Offset; // for k_ARM64 / k_RISCV // UInt32 AlignSizeOpt; // for k_ARM64 - CFilterMode(): - Id(0), - Delta(0), - Offset(0) - // , AlignSizeOpt(0) - {} - void ClearFilterMode() { Id = 0; @@ -437,7 +430,11 @@ struct CFilterMode2: public CFilterMode bool Encrypted; unsigned GroupIndex; - CFilterMode2(): Encrypted(false) {} + void Construct() + { + ClearFilterMode(); + Encrypted = false; + } int Compare(const CFilterMode2 &m) const { @@ -546,6 +543,7 @@ static unsigned Get_FilterGroup_for_Folder( CRecordVector &filters, const CFolderEx &f, bool extractFilter) { CFilterMode2 m; + m.Construct(); // m.Id = 0; // m.Delta = 0; // m.Offset = 0; @@ -795,14 +793,14 @@ struct CRefItem unsigned NamePos; unsigned ExtensionIndex; - CRefItem() {} - CRefItem(UInt32 index, const CUpdateItem &ui, bool sortByType): - UpdateItem(&ui), - Index(index), - ExtensionPos(0), - NamePos(0), - ExtensionIndex(0) + void Construct(UInt32 index, const CUpdateItem &ui, bool sortByType) { + UpdateItem = &ui; + Index = index; + ExtensionPos = 0; + NamePos = 0; + ExtensionIndex = 0; + if (sortByType) { const int slashPos = ui.Name.ReverseFind_PathSepar(); @@ -2154,6 +2152,7 @@ HRESULT Update( continue; CFilterMode2 fm; + fm.Construct(); if (useFilters) { // analysis.ATime_Defined = false; @@ -2710,7 +2709,7 @@ HRESULT Update( unsigned i; for (i = 0; i < numFiles; i++) - refItems[i] = CRefItem(group.Indices[i], updateItems[group.Indices[i]], sortByType); + refItems[i].Construct(group.Indices[i], updateItems[group.Indices[i]], sortByType); CSortParam sortParam; // sortParam.TreeFolders = &treeFolders; diff --git a/CPP/7zip/Archive/ApfsHandler.cpp b/CPP/7zip/Archive/ApfsHandler.cpp index 62b00ed..2876991 100644 --- a/CPP/7zip/Archive/ApfsHandler.cpp +++ b/CPP/7zip/Archive/ApfsHandler.cpp @@ -3487,7 +3487,7 @@ static const CStatProp kProps[] = { NULL, kpidChangeTime, VT_FILETIME }, { "Added Time", kpidAddTime, VT_FILETIME }, { NULL, kpidMethod, VT_BSTR }, - { NULL, kpidINode, VT_UI8 }, + { NULL, kpidINode, VT_UI4 }, { NULL, kpidLinks, VT_UI4 }, { NULL, kpidSymLink, VT_BSTR }, { NULL, kpidUserId, VT_UI4 }, @@ -3496,7 +3496,7 @@ static const CStatProp kProps[] = #ifdef APFS_SHOW_ALT_STREAMS { NULL, kpidIsAltStream, VT_BOOL }, #endif - { "Parent iNode", kpidParentINode, VT_UI8 }, + { "Parent iNode", kpidParentINode, VT_UI4 }, { "Primary Name", kpidPrimeName, VT_BSTR }, { "Generation", kpidGeneration, VT_UI4 }, { "Written Size", kpidBytesWritten, VT_UI8 }, diff --git a/CPP/7zip/Archive/ExtHandler.cpp b/CPP/7zip/Archive/ExtHandler.cpp index 5af2a92..d379373 100644 --- a/CPP/7zip/Archive/ExtHandler.cpp +++ b/CPP/7zip/Archive/ExtHandler.cpp @@ -628,6 +628,8 @@ struct CNode UInt32 Gid; // fixed 21.02 // UInt16 Checksum; + UInt32 NumLinksCalced; + UInt64 FileSize; CExtTime MTime; CExtTime ATime; @@ -639,17 +641,16 @@ struct CNode UInt32 NumLinks; UInt32 Flags; - UInt32 NumLinksCalced; - Byte Block[kNodeBlockFieldSize]; - CNode(): - ParentNode(-1), - ItemIndex(-1), - SymLinkIndex(-1), - DirIndex(-1), - NumLinksCalced(0) - {} + void Construct() + { + ParentNode = -1; + ItemIndex = -1; + SymLinkIndex = -1; + DirIndex = -1; + NumLinksCalced = 0; + } bool IsFlags_HUGE() const { return (Flags & k_NodeFlags_HUGE) != 0; } bool IsFlags_EXTENTS() const { return (Flags & k_NodeFlags_EXTENTS) != 0; } @@ -1172,21 +1173,19 @@ HRESULT CHandler::Open2(IInStream *inStream) { // ---------- Read groups ---------- - CByteBuffer gdBuf; const size_t gdBufSize = (size_t)numGroups << gdBits; if ((gdBufSize >> gdBits) != numGroups) return S_FALSE; + CByteBuffer gdBuf; gdBuf.Alloc(gdBufSize); RINOK(SeekAndRead(inStream, (_h.BlockBits <= 10 ? 2 : 1), gdBuf, gdBufSize)) - for (unsigned i = 0; i < numGroups; i++) + const unsigned gd_Size = (unsigned)1 << gdBits; + const Byte *p = gdBuf; + for (unsigned i = 0; i < numGroups; i++, p += gd_Size) { CGroupDescriptor gd; - - const Byte *p = gdBuf + ((size_t)i << gdBits); - const unsigned gd_Size = (unsigned)1 << gdBits; gd.Parse(p, gd_Size); - if (_h.UseMetadataChecksum()) { // use CRC32c @@ -1228,7 +1227,10 @@ HRESULT CHandler::Open2(IInStream *inStream) if (numNodes > (1 << 24)) return S_FALSE; } - + + const size_t blockSize = (size_t)1 << _h.BlockBits; + if (numNodes > blockSize * 8) + return S_FALSE; const UInt32 numReserveInodes = _h.NumInodes - _h.NumFreeInodes + 1; // numReserveInodes = _h.NumInodes + 1; if (numReserveInodes != 0) @@ -1241,7 +1243,6 @@ HRESULT CHandler::Open2(IInStream *inStream) nodesData.Alloc(nodesDataSize); CByteBuffer nodesMap; - const size_t blockSize = (size_t)1 << _h.BlockBits; nodesMap.Alloc(blockSize); unsigned globalNodeIndex = 0; @@ -1282,6 +1283,7 @@ HRESULT CHandler::Open2(IInStream *inStream) } CNode node; + node.Construct(); PRF(printf("\nnode = %5d ", (unsigned)n)); diff --git a/CPP/7zip/Archive/HfsHandler.cpp b/CPP/7zip/Archive/HfsHandler.cpp index 46e0239..5df00ed 100644 --- a/CPP/7zip/Archive/HfsHandler.cpp +++ b/CPP/7zip/Archive/HfsHandler.cpp @@ -437,7 +437,7 @@ struct CRef int AttrIndex; int Parent; - CRef(): AttrIndex(kAttrIndex_Item), Parent(-1) {} + void Construct() { AttrIndex = kAttrIndex_Item; Parent = -1; } bool IsResource() const { return AttrIndex == kAttrIndex_Resource; } bool IsAltStream() const { return AttrIndex != kAttrIndex_Item; } bool IsItem() const { return AttrIndex == kAttrIndex_Item; } @@ -1259,6 +1259,7 @@ HRESULT CDatabase::LoadCatalog(const CFork &fork, const CObjectVector= _items.Size()) @@ -1070,6 +1068,7 @@ Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val } else { + const CItem &item = _items[index]; switch (propID) { case kpidPath: diff --git a/CPP/7zip/Archive/MbrHandler.cpp b/CPP/7zip/Archive/MbrHandler.cpp index 82d34fd..53663e8 100644 --- a/CPP/7zip/Archive/MbrHandler.cpp +++ b/CPP/7zip/Archive/MbrHandler.cpp @@ -53,7 +53,12 @@ struct CChs SectCyl = p[1]; Cyl8 = p[2]; } - bool Check() const { return GetSector() > 0; } + bool Check() const + { + if ((Head | SectCyl | Cyl8) == 0) + return true; + return GetSector() > 0; + } }; diff --git a/CPP/7zip/Archive/Nsis/NsisIn.cpp b/CPP/7zip/Archive/Nsis/NsisIn.cpp index 194e5bf..577062e 100644 --- a/CPP/7zip/Archive/Nsis/NsisIn.cpp +++ b/CPP/7zip/Archive/Nsis/NsisIn.cpp @@ -190,7 +190,7 @@ static const CCommandInfo k_Commands[kNumCmds] = { 2 }, // "SetFileAttributes" }, { 3 }, // CreateDirectory, SetOutPath { 3 }, // "IfFileExists" }, - { 3 }, // SetRebootFlag, ... + { 4 }, // SetRebootFlag, ... { 4 }, // "If" }, // IfAbort, IfSilent, IfErrors, IfRebootFlag { 2 }, // "Get" }, // GetInstDirError, GetErrorLevel { 4 }, // "Rename" }, @@ -3910,6 +3910,10 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh) if (params[2] != 0) { s += " lastused"; + // (params[3] == (UInt32)(Int32)-1) is possible in NSIS 3.10. + // SetDetailsPrint lastused (special) + if ((Int32)params[3] < 0) + s += " ; (special)"; break; } UInt32 v; diff --git a/CPP/7zip/Archive/NtfsHandler.cpp b/CPP/7zip/Archive/NtfsHandler.cpp index d26612b..006f0ad 100644 --- a/CPP/7zip/Archive/NtfsHandler.cpp +++ b/CPP/7zip/Archive/NtfsHandler.cpp @@ -1433,7 +1433,12 @@ struct CItem int ParentHost; /* index in Items array, if it's AltStream -1: if it's not AltStream */ - CItem(): DataIndex(k_Item_DataIndex_IsDir), ParentFolder(-1), ParentHost(-1) {} + void Construct() + { + DataIndex = k_Item_DataIndex_IsDir; + ParentFolder = -1; + ParentHost = -1; + } bool IsAltStream() const { return ParentHost != -1; } bool IsDir() const { return DataIndex == k_Item_DataIndex_IsDir; } @@ -2060,6 +2065,7 @@ HRESULT CDatabase::Open() } CItem item; + item.Construct(); item.NameIndex = t; item.RecIndex = i; item.DataIndex = rec.IsDir() ? diff --git a/CPP/7zip/Archive/PeHandler.cpp b/CPP/7zip/Archive/PeHandler.cpp index 79f89ef..f5f66b0 100644 --- a/CPP/7zip/Archive/PeHandler.cpp +++ b/CPP/7zip/Archive/PeHandler.cpp @@ -758,7 +758,13 @@ struct CMixItem int StringIndex; int VersionIndex; - CMixItem(): SectionIndex(-1), ResourceIndex(-1), StringIndex(-1), VersionIndex(-1) {} + void Construct() + { + SectionIndex = -1; + ResourceIndex = -1; + StringIndex = -1; + VersionIndex = -1; + } bool IsSectionItem() const { return ResourceIndex < 0 && StringIndex < 0 && VersionIndex < 0; } }; @@ -820,20 +826,22 @@ Z7_CLASS_IMP_CHandler_IInArchive_2( CObjectVector _versionKeys; CByteBuffer _buf; + bool _oneLang; - UString _resourcesPrefix; - CUsedBitmap _usedRes; // bool _parseResources; bool _checksumError; bool _sectionsError; + bool _coffMode; + bool _allowTail; + + UString _resourcesPrefix; + CUsedBitmap _usedRes; + bool IsOpt() const { return _header.OptHeaderSize != 0; } COptHeader _optHeader; - bool _coffMode; - bool _allowTail; - HRESULT LoadDebugSections(IInStream *stream, bool &thereIsSection); HRESULT Open2(IInStream *stream, IArchiveOpenCallback *callback); @@ -2269,6 +2277,7 @@ HRESULT CHandler::OpenResources(unsigned sectionIndex, IInStream *stream, IArchi if (ParseVersion((const Byte *)_buf + offset, item.Size, f, _versionKeys)) { CMixItem mixItem; + mixItem.Construct(); mixItem.VersionIndex = (int)_versionFiles.Size(); mixItem.SectionIndex = (int)sectionIndex; // check it !!!! CByteBuffer_WithLang &vf = _versionFiles.AddNew(); @@ -2300,6 +2309,7 @@ HRESULT CHandler::OpenResources(unsigned sectionIndex, IInStream *stream, IArchi if (_strings[i].FinalSize() == 0) continue; CMixItem mixItem; + mixItem.Construct(); mixItem.StringIndex = (int)i; mixItem.SectionIndex = (int)sectionIndex; _mixItems.Add(mixItem); @@ -2654,6 +2664,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback) if (item.Enabled) { CMixItem mixItem; + mixItem.Construct(); mixItem.SectionIndex = (int)i; mixItem.ResourceIndex = (int)j; if (item.IsRcDataOrUnknown()) @@ -2717,6 +2728,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback) } CMixItem mixItem; + mixItem.Construct(); mixItem.SectionIndex = (int)i; _mixItems.Add(mixItem); } diff --git a/CPP/7zip/Archive/SparseHandler.cpp b/CPP/7zip/Archive/SparseHandler.cpp index 5e666ed..70bcb6f 100644 --- a/CPP/7zip/Archive/SparseHandler.cpp +++ b/CPP/7zip/Archive/SparseHandler.cpp @@ -78,7 +78,7 @@ struct CChunk Byte Fill [kFillSize]; UInt64 PhyOffset; - CChunk() + void Construct() { Fill[0] = Fill[1] = @@ -293,6 +293,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *openCallback) if (size < kChunkHeaderSize) return S_FALSE; CChunk c; + c.Construct(); c.PhyOffset = offset + kChunkHeaderSize; c.VirtBlock = virtBlock; offset += size; @@ -364,6 +365,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *openCallback) { CChunk c; + c.Construct(); c.VirtBlock = virtBlock; c.PhyOffset = offset; Chunks.AddInReserved(c); diff --git a/CPP/7zip/Archive/SquashfsHandler.cpp b/CPP/7zip/Archive/SquashfsHandler.cpp index b66be04..83cb1cf 100644 --- a/CPP/7zip/Archive/SquashfsHandler.cpp +++ b/CPP/7zip/Archive/SquashfsHandler.cpp @@ -812,7 +812,7 @@ struct CItem int Parent; UInt32 Ptr; - CItem(): Node(-1), Parent(-1), Ptr(0) {} + void Construct() { Node = -1; Parent = -1; Ptr = 0; } }; struct CData @@ -1497,7 +1497,7 @@ HRESULT CHandler::OpenDir(int parent, UInt32 startBlock, UInt32 offset, unsigned if (rem == 0) return S_FALSE; - UInt32 nameOffset = _h.GetFileNameOffset(); + const UInt32 nameOffset = _h.GetFileNameOffset(); if (rem < nameOffset) return S_FALSE; @@ -1505,7 +1505,7 @@ HRESULT CHandler::OpenDir(int parent, UInt32 startBlock, UInt32 offset, unsigned return S_FALSE; if (_openCallback) { - UInt64 numFiles = _items.Size(); + const UInt64 numFiles = _items.Size(); if ((numFiles & 0xFFFF) == 0) { RINOK(_openCallback->SetCompleted(&numFiles, NULL)) @@ -1513,6 +1513,7 @@ HRESULT CHandler::OpenDir(int parent, UInt32 startBlock, UInt32 offset, unsigned } CItem item; + item.Construct(); item.Ptr = (UInt32)(p - (const Byte *)_dirs.Data); UInt32 size; diff --git a/CPP/7zip/Archive/Wim/WimHandlerOut.cpp b/CPP/7zip/Archive/Wim/WimHandlerOut.cpp index 3b2cb31..0fd7d23 100644 --- a/CPP/7zip/Archive/Wim/WimHandlerOut.cpp +++ b/CPP/7zip/Archive/Wim/WimHandlerOut.cpp @@ -177,7 +177,12 @@ struct CUpdateItem int InArcIndex; // >= 0, if we use OLD Data // -1, if we use NEW Data - CUpdateItem(): MetaIndex(-1), AltStreamIndex(-1), InArcIndex(-1) {} + void Construct() + { + MetaIndex = -1; + AltStreamIndex = -1; + InArcIndex = -1; + } }; @@ -894,6 +899,7 @@ Z7_COM7F_IMF(CHandler::UpdateItems(ISequentialOutStream *outSeqStream, UInt32 nu for (i = 0; i < numItems; i++) { CUpdateItem ui; + ui.Construct(); UInt32 indexInArchive; Int32 newData, newProps; RINOK(callback->GetUpdateItemInfo(i, &newData, &newProps, &indexInArchive)) diff --git a/CPP/7zip/Archive/Wim/WimIn.cpp b/CPP/7zip/Archive/Wim/WimIn.cpp index b2236dd..33fbe82 100644 --- a/CPP/7zip/Archive/Wim/WimIn.cpp +++ b/CPP/7zip/Archive/Wim/WimIn.cpp @@ -609,6 +609,7 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent, unsigned dirLevel) return S_FALSE; CItem item; + item.Construct(); const UInt32 attrib = Get32(p + 8); item.IsDir = ((attrib & 0x10) != 0); { @@ -729,6 +730,7 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent, unsigned dirLevel) { ThereAreAltStreams = true; CItem item2; + item2.Construct(); item2.Offset = pos; item2.IsAltStream = true; item2.Parent = (int)prevIndex; @@ -1531,6 +1533,7 @@ HRESULT CDatabase::FillAndCheck(const CObjectVector &volumes) if (!r.IsSolidBig() || Solids[r.SolidIndex].FirstSmallStream < 0) { CItem item; + item.Construct(); item.Offset = 0; item.StreamIndex = (int)i; item.ImageIndex = -1; diff --git a/CPP/7zip/Archive/Wim/WimIn.h b/CPP/7zip/Archive/Wim/WimIn.h index 571f414..ae7cd6b 100644 --- a/CPP/7zip/Archive/Wim/WimIn.h +++ b/CPP/7zip/Archive/Wim/WimIn.h @@ -347,15 +347,16 @@ struct CItem bool HasMetadata() const { return ImageIndex >= 0; } - CItem(): - IndexInSorted(-1), - StreamIndex(-1), - Parent(-1), - IsDir(false), - IsAltStream(false), - DirLevel(0), - SubDirOffset(0) - {} + void Construct() + { + IndexInSorted = -1; + StreamIndex = -1; + Parent = -1; + IsDir = false; + IsAltStream = false; + DirLevel = 0; + SubDirOffset = 0; + } }; struct CImage diff --git a/CPP/7zip/Common/CreateCoder.cpp b/CPP/7zip/Common/CreateCoder.cpp index 93113a0..67873d1 100644 --- a/CPP/7zip/Common/CreateCoder.cpp +++ b/CPP/7zip/Common/CreateCoder.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#include "../../Windows/Defs.h" +#include "../../Windows/WinDefs.h" #include "../../Windows/PropVariant.h" #include "CreateCoder.h" diff --git a/CPP/7zip/Common/MethodProps.h b/CPP/7zip/Common/MethodProps.h index be108fa..f7ba569 100644 --- a/CPP/7zip/Common/MethodProps.h +++ b/CPP/7zip/Common/MethodProps.h @@ -6,8 +6,7 @@ #include "../../Common/MyString.h" #include "../../Common/Defs.h" -#include "../../Windows/Defs.h" - +#include "../../Windows/WinDefs.h" #include "../../Windows/PropVariant.h" #include "../ICoder.h" diff --git a/CPP/7zip/Common/PropId.cpp b/CPP/7zip/Common/PropId.cpp index 6117b0e..b00ad81 100644 --- a/CPP/7zip/Common/PropId.cpp +++ b/CPP/7zip/Common/PropId.cpp @@ -3,10 +3,8 @@ #include "StdAfx.h" #include "../../Common/MyWindows.h" - #include "../PropID.h" -// VARTYPE const Byte k7z_PROPID_To_VARTYPE[kpid_NUM_DEFINED] = { VT_EMPTY, @@ -84,7 +82,7 @@ const Byte k7z_PROPID_To_VARTYPE[kpid_NUM_DEFINED] = VT_UI4, VT_BSTR, VT_UI8, - VT_UI8, + VT_UI4, // kpidNumAltStreams VT_UI8, VT_UI8, VT_UI8, diff --git a/CPP/7zip/Compress/CodecExports.cpp b/CPP/7zip/Compress/CodecExports.cpp index e37ae14..70be760 100644 --- a/CPP/7zip/Compress/CodecExports.cpp +++ b/CPP/7zip/Compress/CodecExports.cpp @@ -8,7 +8,7 @@ #include "../../Common/ComTry.h" #include "../../Common/MyCom.h" -#include "../../Windows/Defs.h" +#include "../../Windows/WinDefs.h" #include "../../Windows/PropVariant.h" #include "../ICoder.h" diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp index 903cde2..265b943 100644 --- a/CPP/7zip/UI/Agent/AgentOut.cpp +++ b/CPP/7zip/UI/Agent/AgentOut.cpp @@ -497,6 +497,7 @@ HRESULT CAgent::CreateFolder(ISequentialOutStream *outArchiveStream, updatePairs.Add(up2); } CUpdatePair2 up2; + up2.Construct(); up2.NewData = up2.NewProps = true; up2.UseArcProps = false; up2.DirIndex = 0; diff --git a/CPP/7zip/UI/Agent/AgentProxy.cpp b/CPP/7zip/UI/Agent/AgentProxy.cpp index d04ddab..c8edd19 100644 --- a/CPP/7zip/UI/Agent/AgentProxy.cpp +++ b/CPP/7zip/UI/Agent/AgentProxy.cpp @@ -233,11 +233,26 @@ void CProxyArc::CalculateSizes(unsigned dirIndex, IInArchive *archive) } } + +void CProxyArc::FreeFiles() +{ + const unsigned numFiles = NumFiles; + NumFiles = 0; + CProxyFile *f = Files; + for (unsigned i = 0; i < numFiles; i++, f++) + if (f->NeedDeleteName) + delete [](wchar_t *)(void *)f->Name; + delete []Files; + Files = NULL; +} + +static const UInt32 k_NumFiles_Max = 0x7fffffff - 15; + HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress) { // DWORD tickCount = GetTickCount(); for (int ttt = 0; ttt < 1; ttt++) { - Files.Free(); + FreeFiles(); Dirs.Clear(); Dirs.AddNew(); @@ -245,11 +260,15 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress) UInt32 numItems; RINOK(archive->GetNumberOfItems(&numItems)) + if (numItems > k_NumFiles_Max) + return E_OUTOFMEMORY; if (progress) RINOK(progress->SetTotal(numItems)) - Files.Alloc(numItems); + Z7_ARRAY_NEW(Files, CProxyFile, numItems) + memset(Files, 0, (size_t)numItems * sizeof(*Files)); + NumFiles = numItems; UString path; UString name; @@ -375,6 +394,7 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress) RINOK(Archive_IsItem_Dir(archive, i, isDir)) CProxyFile &f = Files[i]; + f.Construct(); // optional because memset() in code above f.NameLen = len - namePos; s += namePos; @@ -579,6 +599,19 @@ bool CProxyArc2::IsThere_SubDir(unsigned dirIndex, const UString &name) const return false; } + +void CProxyArc2::FreeFiles() +{ + const unsigned numFiles = NumFiles; + NumFiles = 0; + CProxyFile2 *f = Files; + for (unsigned i = 0; i < numFiles; i++, f++) + if (f->NeedDeleteName) + delete [](wchar_t *)(void *)f->Name; + delete []Files; + Files = NULL; +} + HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress) { if (!arc.GetRawProps) @@ -587,12 +620,14 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress) // DWORD tickCount = GetTickCount(); for (int ttt = 0; ttt < 1; ttt++) { Dirs.Clear(); - Files.Free(); + FreeFiles(); IInArchive *archive = arc.Archive; UInt32 numItems; RINOK(archive->GetNumberOfItems(&numItems)) + if (numItems > k_NumFiles_Max) + return E_OUTOFMEMORY; if (progress) RINOK(progress->SetTotal(numItems)) UString fileName; @@ -609,7 +644,9 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress) dir.PathPrefix = ':'; } - Files.Alloc(numItems); + Z7_ARRAY_NEW(Files, CProxyFile2, numItems) + memset(Files, 0, (size_t)numItems * sizeof(*Files)); + NumFiles = numItems; UString tempUString; AString tempAString; @@ -619,11 +656,12 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress) { if (progress && (i & 0xFFFFF) == 0) { - UInt64 currentItemIndex = i; + const UInt64 currentItemIndex = i; RINOK(progress->SetCompleted(¤tItemIndex)) } CProxyFile2 &file = Files[i]; + file.Construct(); const void *p; UInt32 size; diff --git a/CPP/7zip/UI/Agent/AgentProxy.h b/CPP/7zip/UI/Agent/AgentProxy.h index c24dd91..c6736a8 100644 --- a/CPP/7zip/UI/Agent/AgentProxy.h +++ b/CPP/7zip/UI/Agent/AgentProxy.h @@ -11,8 +11,12 @@ struct CProxyFile unsigned NameLen; bool NeedDeleteName; - CProxyFile(): Name(NULL), NameLen(0), NeedDeleteName(false) {} - ~CProxyFile() { if (NeedDeleteName) delete [](wchar_t *)(void *)Name; } // delete [](wchar_t *)Name; + void Construct() + { + Name = NULL; + NameLen = 0; + NeedDeleteName = false; + } }; const unsigned k_Proxy_RootDirIndex = 0; @@ -47,9 +51,14 @@ class CProxyArc void CalculateSizes(unsigned dirIndex, IInArchive *archive); unsigned AddDir(unsigned dirIndex, int arcIndex, const UString &name); + void FreeFiles(); public: CObjectVector Dirs; // Dirs[0] - root - CObjArray Files; // all items from archive in same order + CProxyFile *Files; // all items from archive in same order + unsigned NumFiles; + + CProxyArc(): Files(NULL), NumFiles(0) {} + ~CProxyArc() { FreeFiles(); } // returns index in Dirs[], or -1, int FindSubDir(unsigned dirIndex, const wchar_t *name) const; @@ -83,17 +92,17 @@ struct CProxyFile2 int GetDirIndex(bool forAltStreams) const { return forAltStreams ? AltDirIndex : DirIndex; } bool IsDir() const { return DirIndex != -1; } - CProxyFile2(): - DirIndex(-1), AltDirIndex(-1), Parent(-1), - Name(NULL), NameLen(0), - NeedDeleteName(false), - Ignore(false), - IsAltStream(false) - {} - ~CProxyFile2() + + void Construct() { - if (NeedDeleteName) - delete [](wchar_t *)(void *)Name; + DirIndex = -1; + AltDirIndex = -1; + Parent = -1; + Name = NULL; + NameLen = 0; + NeedDeleteName = false; + Ignore = false; + IsAltStream = false; } }; @@ -110,8 +119,6 @@ struct CProxyDir2 UInt32 NumSubFiles; CProxyDir2(): ArcIndex(-1) {} - void AddFileSubItem(UInt32 index, const UString &name); - void Clear(); }; const unsigned k_Proxy2_RootDirIndex = k_Proxy_RootDirIndex; @@ -123,10 +130,15 @@ class CProxyArc2 void CalculateSizes(unsigned dirIndex, IInArchive *archive); // AddRealIndices_of_Dir DOES NOT ADD item itself represented by dirIndex void AddRealIndices_of_Dir(unsigned dirIndex, bool includeAltStreams, CUIntVector &realIndices) const; + void FreeFiles(); public: CObjectVector Dirs; // Dirs[0] - root folder // Dirs[1] - for alt streams of root dir - CObjArray Files; // all items from archive in same order + CProxyFile2 *Files; // all items from archive in same order + unsigned NumFiles; + + CProxyArc2(): Files(NULL), NumFiles(0) {} + ~CProxyArc2() { FreeFiles(); } bool IsThere_SubDir(unsigned dirIndex, const UString &name) const; diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp index 6631629..7f6da0c 100644 --- a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp +++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp @@ -1842,6 +1842,11 @@ Z7_COM7F_IMF(CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre outStreamLoc = new CStdOutFileStream; else { + if (_isSplit) + { + RINOK(PrepareOperation(askExtractMode)) + return SetOperationResult(NArchive::NExtract::NOperationResult::kUnsupportedMethod); + } bool needExit = true; RINOK(GetExtractStream(outStreamLoc, needExit)) if (needExit) @@ -2674,6 +2679,7 @@ Z7_COM7F_IMF(CArchiveExtractCallback::SetOperationResult(Int32 opRes)) { COM_TRY_BEGIN + // if (_isSplit) opRes = NArchive::NExtract::NOperationResult::kUnsupportedMethod; // printf("\nCArchiveExtractCallback::SetOperationResult: %d %s\n", opRes, GetAnsiString(_diskFilePath)); #ifndef Z7_SFX diff --git a/CPP/7zip/UI/Common/LoadCodecs.cpp b/CPP/7zip/UI/Common/LoadCodecs.cpp index e71158c..c944ee9 100644 --- a/CPP/7zip/UI/Common/LoadCodecs.cpp +++ b/CPP/7zip/UI/Common/LoadCodecs.cpp @@ -211,10 +211,11 @@ static FString GetBaseFolderPrefixFromRegistry() && !NFind::DoesFileOrDirExist(moduleFolderPrefix + kFormatsFolderName)) { FString path; - if (ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPath2Value, path)) return path; - if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPath2Value, path)) return path; - if (ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPathValue, path)) return path; - if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPathValue, path)) return path; + if ( ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPath2Value, path) + || ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPath2Value, path) + || ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPathValue, path) + || ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPathValue, path)) + moduleFolderPrefix = path; } #endif diff --git a/CPP/7zip/UI/Common/UpdatePair.cpp b/CPP/7zip/UI/Common/UpdatePair.cpp index 99b0aaf..8fc5615 100644 --- a/CPP/7zip/UI/Common/UpdatePair.cpp +++ b/CPP/7zip/UI/Common/UpdatePair.cpp @@ -196,6 +196,7 @@ void GetUpdatePairInfoList( while (dirIndex < numDirItems || arcIndex < numArcItems) { CUpdatePair pair; + pair.Construct(); int dirIndex2 = -1; int arcIndex2 = -1; diff --git a/CPP/7zip/UI/Common/UpdatePair.h b/CPP/7zip/UI/Common/UpdatePair.h index 13228b0..a2855c4 100644 --- a/CPP/7zip/UI/Common/UpdatePair.h +++ b/CPP/7zip/UI/Common/UpdatePair.h @@ -15,7 +15,7 @@ struct CUpdatePair int DirIndex; int HostIndex; // >= 0 for alt streams only, contains index of host pair - CUpdatePair(): ArcIndex(-1), DirIndex(-1), HostIndex(-1) {} + void Construct() { ArcIndex = -1; DirIndex = -1; HostIndex = -1; } }; void GetUpdatePairInfoList( diff --git a/CPP/7zip/UI/Common/UpdateProduce.cpp b/CPP/7zip/UI/Common/UpdateProduce.cpp index 88d2501..9b66d36 100644 --- a/CPP/7zip/UI/Common/UpdateProduce.cpp +++ b/CPP/7zip/UI/Common/UpdateProduce.cpp @@ -19,6 +19,7 @@ void UpdateProduce( const CUpdatePair &pair = updatePairs[i]; CUpdatePair2 up2; + up2.Construct(); up2.DirIndex = pair.DirIndex; up2.ArcIndex = pair.ArcIndex; up2.NewData = up2.NewProps = true; diff --git a/CPP/7zip/UI/Common/UpdateProduce.h b/CPP/7zip/UI/Common/UpdateProduce.h index 9db6c1e..3d16381 100644 --- a/CPP/7zip/UI/Common/UpdateProduce.h +++ b/CPP/7zip/UI/Common/UpdateProduce.h @@ -19,28 +19,28 @@ struct CUpdatePair2 bool IsMainRenameItem; bool IsSameTime; + void Construct() + { + NewData = false; + NewProps = false; + UseArcProps = false; + IsAnti = false; + DirIndex = -1; + ArcIndex = -1; + NewNameIndex = -1; + IsMainRenameItem = false; + IsSameTime = false; + } + void SetAs_NoChangeArcItem(unsigned arcIndex) // int { - NewData = NewProps = false; + Construct(); UseArcProps = true; - IsAnti = false; ArcIndex = (int)arcIndex; } bool ExistOnDisk() const { return DirIndex != -1; } bool ExistInArchive() const { return ArcIndex != -1; } - - CUpdatePair2(): - NewData(false), - NewProps(false), - UseArcProps(false), - IsAnti(false), - DirIndex(-1), - ArcIndex(-1), - NewNameIndex(-1), - IsMainRenameItem(false), - IsSameTime(false) - {} }; Z7_PURE_INTERFACES_BEGIN diff --git a/CPP/7zip/UI/Far/FarUtils.cpp b/CPP/7zip/UI/Far/FarUtils.cpp index 3c33d8e..1d331e9 100644 --- a/CPP/7zip/UI/Far/FarUtils.cpp +++ b/CPP/7zip/UI/Far/FarUtils.cpp @@ -8,7 +8,7 @@ #ifndef UNDER_CE #include "../../../Windows/Console.h" #endif -#include "../../../Windows/Defs.h" +#include "../../../Windows/WinDefs.h" #include "../../../Windows/ErrorMsg.h" #include "FarUtils.h" @@ -259,17 +259,15 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const char *keyName, regKey.SetValue(valueName, value); } +/* CSysString CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName, LPCTSTR valueName, const CSysString &valueDefault) const { - NRegistry::CKey regKey; - if (OpenRegKey(parentKey, keyName, regKey) != ERROR_SUCCESS) - return valueDefault; - CSysString value; - if (regKey.QueryValue(valueName, value) != ERROR_SUCCESS) - return valueDefault; - + NRegistry::CKey regKey; + if (OpenRegKey(parentKey, keyName, regKey) != ERROR_SUCCESS + || regKey.QueryValue(valueName, value) != ERROR_SUCCESS) + value = valueDefault; return value; } @@ -286,6 +284,7 @@ UInt32 CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName, return value; } +*/ bool CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName, LPCTSTR valueName, bool valueDefault) const diff --git a/CPP/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp index b7f91d6..f04f712 100644 --- a/CPP/7zip/UI/Far/Plugin.cpp +++ b/CPP/7zip/UI/Far/Plugin.cpp @@ -143,8 +143,13 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) panelItem.Reserved[1] = 0; } + +static const UInt32 k_NumFiles_Max = 0x7fffffff - 15; + int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opMode) { + *panelItems = NULL; + *itemsNumber = 0; // CScreenRestorer screenRestorer; if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0) { @@ -160,8 +165,13 @@ int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opM } UInt32 numItems; - _folder->GetNumberOfItems(&numItems); - *panelItems = new PluginPanelItem[numItems]; + if (_folder->GetNumberOfItems(&numItems) != S_OK) + return FALSE; + if (numItems > k_NumFiles_Max) + return FALSE; + + Z7_ARRAY_NEW(*panelItems, PluginPanelItem, numItems) + memset(*panelItems, 0, (size_t)numItems * sizeof(PluginPanelItem)); try { for (UInt32 i = 0; i < numItems; i++) @@ -174,6 +184,7 @@ int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opM catch(...) { delete [](*panelItems); + *panelItems = NULL; throw; } *itemsNumber = (int)numItems; diff --git a/CPP/7zip/UI/FileManager/BrowseDialog2.cpp b/CPP/7zip/UI/FileManager/BrowseDialog2.cpp index 9f083c5..f8bfcb5 100644 --- a/CPP/7zip/UI/FileManager/BrowseDialog2.cpp +++ b/CPP/7zip/UI/FileManager/BrowseDialog2.cpp @@ -95,15 +95,16 @@ struct CBrowseItem UInt32 NumRootItems; UInt64 Size; - CBrowseItem(): - // MainFileIndex(0), - SubFileIndex(-1), - WasInterrupted(false), - NumFiles(0), - NumDirs(0), - NumRootItems(0), - Size(0) - {} + void Construct() + { + // MainFileIndex = 0; + SubFileIndex = -1; + WasInterrupted = false; + NumFiles = 0; + NumDirs = 0; + NumRootItems = 0; + Size = 0; + } }; @@ -114,6 +115,10 @@ struct CBrowseEnumerator CFileInfo fi_SubFile; CBrowseItem bi; + CBrowseEnumerator() + { + bi.Construct(); + } void Enumerate(unsigned level); bool NeedInterrupt() const { @@ -1504,6 +1509,7 @@ HRESULT CBrowseDialog2::Reload(const UString &pathPrefix, const UStringVector &s if (d.Len() < 2 || d.Back() != '\\') return E_FAIL; CBrowseItem item; + item.Construct(); item.MainFileIndex = files.Size(); CFileInfo &fi = files.AddNew(); fi.SetAsDir(); @@ -1552,6 +1558,7 @@ HRESULT CBrowseDialog2::Reload(const UString &pathPrefix, const UStringVector &s } } CBrowseItem item; + item.Construct(); item.MainFileIndex = files.Size(); item.Size = fi.Size; files.Add(fi); diff --git a/CPP/Common/Common0.h b/CPP/Common/Common0.h index 5781a95..a6b842d 100644 --- a/CPP/Common/Common0.h +++ b/CPP/Common/Common0.h @@ -162,7 +162,7 @@ if compiled with new GCC libstdc++, GCC libstdc++ can use: So we can use Z7_ARRAY_NEW macro instead of new[] operator. */ #if defined(_MSC_VER) && (_MSC_VER == 1200) && !defined(_WIN64) - #define Z7_ARRAY_NEW(p, T, size) p = new T[((size) > 0xFFFFFFFFu / sizeof(T)) ? 0xFFFFFFFFu / sizeof(T) : (size)]; + #define Z7_ARRAY_NEW(p, T, size) p = new T[((size) > (0xFFFFFFFFu - 0x7fu) / sizeof(T)) ? (0xFFFFFFFFu - 0x7fu) / sizeof(T) : (size)]; #else #define Z7_ARRAY_NEW(p, T, size) p = new T[size]; #endif diff --git a/CPP/Windows/Clipboard.cpp b/CPP/Windows/Clipboard.cpp index bc7e201..d39c264 100644 --- a/CPP/Windows/Clipboard.cpp +++ b/CPP/Windows/Clipboard.cpp @@ -9,7 +9,7 @@ #include "../Common/StringConvert.h" #include "Clipboard.h" -#include "Defs.h" +#include "WinDefs.h" #include "MemoryGlobal.h" #include "Shell.h" diff --git a/CPP/Windows/CommonDialog.cpp b/CPP/Windows/CommonDialog.cpp index 7a92d5f..2e3f297 100644 --- a/CPP/Windows/CommonDialog.cpp +++ b/CPP/Windows/CommonDialog.cpp @@ -13,7 +13,7 @@ #endif #include "CommonDialog.h" -#include "Defs.h" +#include "WinDefs.h" // #include "FileDir.h" #ifndef _UNICODE diff --git a/CPP/Windows/Console.h b/CPP/Windows/Console.h index 818b8d4..6b494c8 100644 --- a/CPP/Windows/Console.h +++ b/CPP/Windows/Console.h @@ -3,7 +3,7 @@ #ifndef ZIP7_INC_WINDOWS_CONSOLE_H #define ZIP7_INC_WINDOWS_CONSOLE_H -#include "Defs.h" +#include "WinDefs.h" namespace NWindows { namespace NConsole { diff --git a/CPP/Windows/Control/ImageList.h b/CPP/Windows/Control/ImageList.h index 688f177..c10eea7 100644 --- a/CPP/Windows/Control/ImageList.h +++ b/CPP/Windows/Control/ImageList.h @@ -5,7 +5,7 @@ #include -#include "../Defs.h" +#include "../WinDefs.h" namespace NWindows { namespace NControl { diff --git a/CPP/Windows/FileFind.h b/CPP/Windows/FileFind.h index 944bca2..9ae1115 100644 --- a/CPP/Windows/FileFind.h +++ b/CPP/Windows/FileFind.h @@ -13,8 +13,6 @@ #include "../Common/MyString.h" #include "../Common/MyWindows.h" -#include "Defs.h" - #include "FileIO.h" namespace NWindows { diff --git a/CPP/Windows/FileIO.h b/CPP/Windows/FileIO.h index 26edef4..a202df5 100644 --- a/CPP/Windows/FileIO.h +++ b/CPP/Windows/FileIO.h @@ -31,7 +31,7 @@ #include "../Windows/TimeUtils.h" -#include "Defs.h" +#include "WinDefs.h" HRESULT GetLastError_noZero_HRESULT(); diff --git a/CPP/Windows/FileSystem.cpp b/CPP/Windows/FileSystem.cpp index b402306..6cb9808 100644 --- a/CPP/Windows/FileSystem.cpp +++ b/CPP/Windows/FileSystem.cpp @@ -9,7 +9,7 @@ #endif #include "FileSystem.h" -#include "Defs.h" +#include "WinDefs.h" #ifndef _UNICODE extern bool g_IsNT; diff --git a/CPP/Windows/Menu.h b/CPP/Windows/Menu.h index e1de4c4..00aa692 100644 --- a/CPP/Windows/Menu.h +++ b/CPP/Windows/Menu.h @@ -6,7 +6,7 @@ #include "../Common/MyWindows.h" #include "../Common/MyString.h" -#include "Defs.h" +#include "WinDefs.h" namespace NWindows { diff --git a/CPP/Windows/ProcessUtils.h b/CPP/Windows/ProcessUtils.h index b1fce3a..34fef8d 100644 --- a/CPP/Windows/ProcessUtils.h +++ b/CPP/Windows/ProcessUtils.h @@ -39,7 +39,7 @@ typedef PROCESS_MEMORY_COUNTERS *PPROCESS_MEMORY_COUNTERS; #include "../Common/MyString.h" -#include "Defs.h" +#include "WinDefs.h" #include "Handle.h" namespace NWindows { diff --git a/CPP/Windows/PropVariantConv.cpp b/CPP/Windows/PropVariantConv.cpp index 21a7b4e..467c0f8 100644 --- a/CPP/Windows/PropVariantConv.cpp +++ b/CPP/Windows/PropVariantConv.cpp @@ -4,7 +4,7 @@ #include "../Common/IntToString.h" -#include "Defs.h" +#include "WinDefs.h" #include "PropVariantConv.h" #define UINT_TO_STR_2(c, val) { s[0] = (c); s[1] = (char)('0' + (val) / 10); s[2] = (char)('0' + (val) % 10); s += 3; } diff --git a/CPP/Windows/SecurityUtils.h b/CPP/Windows/SecurityUtils.h index 022a8f3..9775d09 100644 --- a/CPP/Windows/SecurityUtils.h +++ b/CPP/Windows/SecurityUtils.h @@ -9,7 +9,7 @@ #include #endif -#include "Defs.h" +#include "WinDefs.h" #ifndef _UNICODE diff --git a/CPP/Windows/Shell.h b/CPP/Windows/Shell.h index 9e58e25..163c7d9 100644 --- a/CPP/Windows/Shell.h +++ b/CPP/Windows/Shell.h @@ -12,7 +12,7 @@ #include "../Common/MyString.h" -#include "Defs.h" +#include "WinDefs.h" namespace NWindows { namespace NShell { diff --git a/CPP/Windows/Synchronization.h b/CPP/Windows/Synchronization.h index 1df84d3..25764b8 100644 --- a/CPP/Windows/Synchronization.h +++ b/CPP/Windows/Synchronization.h @@ -7,7 +7,7 @@ #include "../Common/MyTypes.h" -#include "Defs.h" +#include "WinDefs.h" #ifdef _WIN32 #include "Handle.h" diff --git a/CPP/Windows/Thread.h b/CPP/Windows/Thread.h index 75c1616..028267b 100644 --- a/CPP/Windows/Thread.h +++ b/CPP/Windows/Thread.h @@ -5,7 +5,7 @@ #include "../../C/Threads.h" -#include "Defs.h" +#include "WinDefs.h" namespace NWindows { diff --git a/CPP/Windows/TimeUtils.cpp b/CPP/Windows/TimeUtils.cpp index 4e3bc59..c83f75d 100644 --- a/CPP/Windows/TimeUtils.cpp +++ b/CPP/Windows/TimeUtils.cpp @@ -7,8 +7,8 @@ #include #endif -#include "Defs.h" #include "TimeUtils.h" +#include "WinDefs.h" namespace NWindows { namespace NTime { diff --git a/CPP/Windows/Defs.h b/CPP/Windows/WinDefs.h similarity index 83% rename from CPP/Windows/Defs.h rename to CPP/Windows/WinDefs.h index 8ab9cf5..86512d2 100644 --- a/CPP/Windows/Defs.h +++ b/CPP/Windows/WinDefs.h @@ -1,7 +1,7 @@ // Windows/Defs.h -#ifndef ZIP7_INC_WINDOWS_DEFS_H -#define ZIP7_INC_WINDOWS_DEFS_H +#ifndef ZIP7_INC_WINDOWS_WIN_DEFS_H +#define ZIP7_INC_WINDOWS_WIN_DEFS_H #include "../Common/MyWindows.h" diff --git a/CPP/Windows/Window.h b/CPP/Windows/Window.h index a99143b..b0ddef9 100644 --- a/CPP/Windows/Window.h +++ b/CPP/Windows/Window.h @@ -6,7 +6,7 @@ #include "../Common/MyWindows.h" #include "../Common/MyString.h" -#include "Defs.h" +#include "WinDefs.h" #ifndef UNDER_CE #ifdef WM_CHANGEUISTATE diff --git a/DOC/7zip.wxs b/DOC/7zip.wxs index 9ec9cf9..44e71e1 100644 --- a/DOC/7zip.wxs +++ b/DOC/7zip.wxs @@ -1,7 +1,7 @@ - + diff --git a/DOC/readme.txt b/DOC/readme.txt index e0048cf..fd01e3b 100644 --- a/DOC/readme.txt +++ b/DOC/readme.txt @@ -1,4 +1,4 @@ -7-Zip 26.01 Sources +7-Zip 26.02 Sources ------------------- 7-Zip is a file archiver for Windows. diff --git a/DOC/src-history.txt b/DOC/src-history.txt index 8f507b0..7858175 100644 --- a/DOC/src-history.txt +++ b/DOC/src-history.txt @@ -1,6 +1,11 @@ HISTORY of the 7-Zip source code -------------------------------- +26.02 2026-06-25 +------------------------- +- Some bugs and vulnerabilities were fixed. + + 26.01 2026-04-27 ------------------------- - linux version of 7-Zip can use huge pages (2 MB pages). It can increase compression