This commit is contained in:
Igor Pavlov 2026-06-25 00:00:00 +00:00
parent 8c63d71ff8
commit f9d78aff31
63 changed files with 730 additions and 640 deletions

File diff suppressed because it is too large Load diff

View file

@ -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"

View file

@ -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

View file

@ -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++;

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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 != ' ')

View file

@ -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;
}

View file

@ -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';
}

View file

@ -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 <stdlib.h>
#include <string.h>
@ -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;

View file

@ -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;

View file

@ -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<CFilterMode2> &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;

View file

@ -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 },

View file

@ -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));

View file

@ -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<CIdExtents
IdToIndexMap.Add(pair);
CRef ref;
ref.Construct();
ref.ItemIndex = i;
Refs.Add(ref);
@ -1317,6 +1318,7 @@ HRESULT CDatabase::LoadCatalog(const CFork &fork, const CObjectVector<CIdExtents
ThereAreAltStreams = true;
CRef ref;
ref.Construct();
ref.AttrIndex = (int)i;
ref.Parent = refIndex;
ref.ItemIndex = Refs[refIndex].ItemIndex;

View file

@ -223,12 +223,13 @@ struct CPartition
UInt64 GetSize() const { return NumSectors << kSectorSizeLog; }
UInt64 GetPackSize() const { return NumSectors_Pack << kSectorSizeLog; }
CPartition():
MethodsMask(0),
NumSectors(0),
NumSectors_Pack(0),
Ext(NULL)
{}
void Construct()
{
MethodsMask = 0;
NumSectors = 0;
NumSectors_Pack = 0;
Ext = NULL;
}
};
@ -609,6 +610,7 @@ HRESULT CHandler::Open2(IInStream *stream)
for (UInt32 i = 0; i < d.num_entries; i++)
{
CPartition part;
part.Construct();
part.Parse(buffer + d.offset + i * d.entry_size);
const UInt32 extLimit = part.first_extent_index + part.num_extents;
if (extLimit < part.first_extent_index ||

View file

@ -1050,8 +1050,6 @@ Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
COM_TRY_BEGIN
NCOM::CPropVariant prop;
const CItem &item = _items[index];
// const CLogVol &item = _items[index];
if (index >= _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:

View file

@ -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;
}
};

View file

@ -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;

View file

@ -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() ?

View file

@ -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<CStringKeyValue> _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);
}

View file

@ -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);

View file

@ -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;

View file

@ -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))

View file

@ -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<CVolume> &volumes)
if (!r.IsSolidBig() || Solids[r.SolidIndex].FirstSmallStream < 0)
{
CItem item;
item.Construct();
item.Offset = 0;
item.StreamIndex = (int)i;
item.ImageIndex = -1;

View file

@ -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

View file

@ -2,7 +2,7 @@
#include "StdAfx.h"
#include "../../Windows/Defs.h"
#include "../../Windows/WinDefs.h"
#include "../../Windows/PropVariant.h"
#include "CreateCoder.h"

View file

@ -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"

View file

@ -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,

View file

@ -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"

View file

@ -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;

View file

@ -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(&currentItemIndex))
}
CProxyFile2 &file = Files[i];
file.Construct();
const void *p;
UInt32 size;

View file

@ -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<CProxyDir> Dirs; // Dirs[0] - root
CObjArray<CProxyFile> 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<CProxyDir2> Dirs; // Dirs[0] - root folder
// Dirs[1] - for alt streams of root dir
CObjArray<CProxyFile2> 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;

View file

@ -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

View file

@ -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

View file

@ -196,6 +196,7 @@ void GetUpdatePairInfoList(
while (dirIndex < numDirItems || arcIndex < numArcItems)
{
CUpdatePair pair;
pair.Construct();
int dirIndex2 = -1;
int arcIndex2 = -1;

View file

@ -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(

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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);

View file

@ -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

View file

@ -9,7 +9,7 @@
#include "../Common/StringConvert.h"
#include "Clipboard.h"
#include "Defs.h"
#include "WinDefs.h"
#include "MemoryGlobal.h"
#include "Shell.h"

View file

@ -13,7 +13,7 @@
#endif
#include "CommonDialog.h"
#include "Defs.h"
#include "WinDefs.h"
// #include "FileDir.h"
#ifndef _UNICODE

View file

@ -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 {

View file

@ -5,7 +5,7 @@
#include <CommCtrl.h>
#include "../Defs.h"
#include "../WinDefs.h"
namespace NWindows {
namespace NControl {

View file

@ -13,8 +13,6 @@
#include "../Common/MyString.h"
#include "../Common/MyWindows.h"
#include "Defs.h"
#include "FileIO.h"
namespace NWindows {

View file

@ -31,7 +31,7 @@
#include "../Windows/TimeUtils.h"
#include "Defs.h"
#include "WinDefs.h"
HRESULT GetLastError_noZero_HRESULT();

View file

@ -9,7 +9,7 @@
#endif
#include "FileSystem.h"
#include "Defs.h"
#include "WinDefs.h"
#ifndef _UNICODE
extern bool g_IsNT;

View file

@ -6,7 +6,7 @@
#include "../Common/MyWindows.h"
#include "../Common/MyString.h"
#include "Defs.h"
#include "WinDefs.h"
namespace NWindows {

View file

@ -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 {

View file

@ -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; }

View file

@ -9,7 +9,7 @@
#include <NTSecAPI.h>
#endif
#include "Defs.h"
#include "WinDefs.h"
#ifndef _UNICODE

View file

@ -12,7 +12,7 @@
#include "../Common/MyString.h"
#include "Defs.h"
#include "WinDefs.h"
namespace NWindows {
namespace NShell {

View file

@ -7,7 +7,7 @@
#include "../Common/MyTypes.h"
#include "Defs.h"
#include "WinDefs.h"
#ifdef _WIN32
#include "Handle.h"

View file

@ -5,7 +5,7 @@
#include "../../C/Threads.h"
#include "Defs.h"
#include "WinDefs.h"
namespace NWindows {

View file

@ -7,8 +7,8 @@
#include <time.h>
#endif
#include "Defs.h"
#include "TimeUtils.h"
#include "WinDefs.h"
namespace NWindows {
namespace NTime {

View file

@ -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"

View file

@ -6,7 +6,7 @@
#include "../Common/MyWindows.h"
#include "../Common/MyString.h"
#include "Defs.h"
#include "WinDefs.h"
#ifndef UNDER_CE
#ifdef WM_CHANGEUISTATE

View file

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?define VerMajor = "26" ?>
<?define VerMinor = "01" ?>
<?define VerMinor = "02" ?>
<?define VerBuild = "00" ?>
<?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?>
<?define MmHex = "$(var.VerMajor)$(var.VerMinor)" ?>

View file

@ -1,4 +1,4 @@
7-Zip 26.01 Sources
7-Zip 26.02 Sources
-------------------
7-Zip is a file archiver for Windows.

View file

@ -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