Update LZMA to 16.04 (security and portability fixes)

This commit is contained in:
Vas Crabb 2016-11-18 20:35:18 +11:00
parent ae4b0cdcf2
commit bb99eba11d
64 changed files with 601 additions and 343 deletions

View File

@ -1,5 +1,5 @@
/* 7zArcIn.c -- 7z Input functions
2016-03-31 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@ -1100,13 +1100,11 @@ static SRes SzReadHeader2(
ISzAlloc *allocTemp
)
{
UInt64 type;
UInt32 numFiles = 0;
UInt32 numEmptyStreams = 0;
CSubStreamInfo ssi;
const Byte *emptyStreams = NULL;
const Byte *emptyFiles = NULL;
{
UInt64 type;
SzData_Clear(&ssi.sdSizes);
SzData_Clear(&ssi.sdCRCs);
SzData_Clear(&ssi.sdNumSubStreams);
@ -1120,9 +1118,9 @@ static SRes SzReadHeader2(
{
for (;;)
{
UInt64 type;
RINOK(ReadID(sd, &type));
if (type == k7zIdEnd)
UInt64 type2;
RINOK(ReadID(sd, &type2));
if (type2 == k7zIdEnd)
break;
RINOK(SkipData(sd));
}
@ -1160,6 +1158,13 @@ static SRes SzReadHeader2(
if (type != k7zIdFilesInfo)
return SZ_ERROR_ARCHIVE;
}
{
UInt32 numFiles = 0;
UInt32 numEmptyStreams = 0;
const Byte *emptyStreams = NULL;
const Byte *emptyFiles = NULL;
RINOK(SzReadNumber32(sd, &numFiles));
p->NumFiles = numFiles;
@ -1458,7 +1463,7 @@ static SRes SzReadHeader2(
if (ssi.sdNumSubStreams.Data && ssi.sdNumSubStreams.Size != 0)
return SZ_ERROR_ARCHIVE;
}
}
return SZ_OK;
}

View File

@ -1,9 +1,9 @@
#define MY_VER_MAJOR 16
#define MY_VER_MINOR 00
#define MY_VER_MINOR 04
#define MY_VER_BUILD 0
#define MY_VERSION_NUMBERS "16.00"
#define MY_VERSION "16.00"
#define MY_DATE "2016-05-10"
#define MY_VERSION_NUMBERS "16.04"
#define MY_VERSION "16.04"
#define MY_DATE "2016-10-04"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov"

10
3rdparty/lzma/C/Aes.c vendored
View File

@ -1,5 +1,5 @@
/* Aes.c -- AES encryption / decryption
2015-02-23 : Igor Pavlov : Public domain */
2016-05-21 : Igor Pavlov : Public domain */
#include "Precomp.h"
@ -167,10 +167,10 @@ void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *w, const Byte *key, unsigned keySize)
{
UInt32 r = w[i];
w[i] =
D[ Sbox[gb0(r)]] ^
D[0x100 + Sbox[gb1(r)]] ^
D[0x200 + Sbox[gb2(r)]] ^
D[0x300 + Sbox[gb3(r)]];
D[ (unsigned)Sbox[gb0(r)]] ^
D[0x100 + (unsigned)Sbox[gb1(r)]] ^
D[0x200 + (unsigned)Sbox[gb2(r)]] ^
D[0x300 + (unsigned)Sbox[gb3(r)]];
}
}

View File

@ -1,5 +1,5 @@
/* CpuArch.h -- CPU specific code
2015-12-01: Igor Pavlov : Public domain */
2016-06-09: Igor Pavlov : Public domain */
#ifndef __CPU_ARCH_H
#define __CPU_ARCH_H
@ -66,6 +66,7 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
|| defined(__MIPSEL__) \
|| defined(__MIPSEL) \
|| defined(_MIPSEL) \
|| defined(__BFIN__) \
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
#define MY_CPU_LE
#endif

87
3rdparty/lzma/C/DllSecur.c vendored Normal file
View File

@ -0,0 +1,87 @@
/* DllSecur.c -- DLL loading security
2016-10-04 : Igor Pavlov : Public domain */
#include "Precomp.h"
#ifdef _WIN32
#include <windows.h>
#include "DllSecur.h"
#ifndef UNDER_CE
typedef BOOL (WINAPI *Func_SetDefaultDllDirectories)(DWORD DirectoryFlags);
#define MY_LOAD_LIBRARY_SEARCH_USER_DIRS 0x400
#define MY_LOAD_LIBRARY_SEARCH_SYSTEM32 0x800
static const char * const g_Dlls =
#ifndef _CONSOLE
"UXTHEME\0"
#endif
"USERENV\0"
"SETUPAPI\0"
"APPHELP\0"
"PROPSYS\0"
"DWMAPI\0"
"CRYPTBASE\0"
"OLEACC\0"
"CLBCATQ\0"
;
#endif
void LoadSecurityDlls()
{
#ifndef UNDER_CE
wchar_t buf[MAX_PATH + 100];
{
// at Vista (ver 6.0) : CoCreateInstance(CLSID_ShellLink, ...) doesn't work after SetDefaultDllDirectories() : Check it ???
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof(vi);
if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0)
{
Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories)
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
if (setDllDirs)
if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS))
return;
}
}
{
unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2);
if (len == 0 || len > MAX_PATH)
return;
}
{
const char *dll;
unsigned pos = (unsigned)lstrlenW(buf);
if (buf[pos - 1] != '\\')
buf[pos++] = '\\';
for (dll = g_Dlls; dll[0] != 0;)
{
unsigned k = 0;
for (;;)
{
char c = *dll++;
buf[pos + k] = c;
k++;
if (c == 0)
break;
}
lstrcatW(buf, L".dll");
LoadLibraryExW(buf, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
}
}
#endif
}
#endif

19
3rdparty/lzma/C/DllSecur.h vendored Normal file
View File

@ -0,0 +1,19 @@
/* DllSecur.h -- DLL loading for security
2016-06-08 : Igor Pavlov : Public domain */
#ifndef __DLL_SECUR_H
#define __DLL_SECUR_H
#include "7zTypes.h"
EXTERN_C_BEGIN
#ifdef _WIN32
void LoadSecurityDlls();
#endif
EXTERN_C_END
#endif

View File

@ -1,5 +1,5 @@
/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
2015-11-08 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@ -9,9 +9,6 @@
#include "Bra.h"
#include "LzmaDec.h"
static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }
SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
{
unsigned i;
@ -25,7 +22,6 @@ SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)
{
ISzAlloc g_Alloc = { SzAlloc, SzFree };
SRes res;
int useFilter;
SizeT inSizePure;

View File

@ -1,5 +1,5 @@
/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
2015-11-08 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@ -13,13 +13,9 @@
#define SZE_OUT_OVERFLOW SZE_DATA_ERROR
static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }
int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
int level, UInt32 dictSize, int filterMode)
{
ISzAlloc g_Alloc = { SzAlloc, SzFree };
size_t outSize2 = *destLen;
Byte *filteredStream;
Bool useFilter;

View File

@ -1,5 +1,5 @@
/* LzmaDec.c -- LZMA Decoder
2015-06-23 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@ -294,14 +294,14 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
#ifdef _LZMA_SIZE_OPT
{
unsigned limit, offset;
unsigned lim, offset;
CLzmaProb *probLen = prob + LenChoice;
IF_BIT_0(probLen)
{
UPDATE_0(probLen);
probLen = prob + LenLow + (posState << kLenNumLowBits);
offset = 0;
limit = (1 << kLenNumLowBits);
lim = (1 << kLenNumLowBits);
}
else
{
@ -312,17 +312,17 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
UPDATE_0(probLen);
probLen = prob + LenMid + (posState << kLenNumMidBits);
offset = kLenNumLowSymbols;
limit = (1 << kLenNumMidBits);
lim = (1 << kLenNumMidBits);
}
else
{
UPDATE_1(probLen);
probLen = prob + LenHigh;
offset = kLenNumLowSymbols + kLenNumMidSymbols;
limit = (1 << kLenNumHighBits);
lim = (1 << kLenNumHighBits);
}
}
TREE_DECODE(probLen, limit, len);
TREE_DECODE(probLen, lim, len);
len += offset;
}
#else

View File

@ -1,5 +1,5 @@
/* LzmaEnc.c -- LZMA Encoder
2015-11-08 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@ -108,7 +108,7 @@ UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
#define kDicLogSizeMaxCompress 32
#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
#define BSR2_RET(pos, res) { unsigned long zz; _BitScanReverse(&zz, (pos)); res = (zz + zz) + ((pos >> (zz - 1)) & 1); }
static UInt32 GetPosSlot1(UInt32 pos)
{
@ -145,19 +145,19 @@ static void LzmaEnc_FastPosInit(Byte *g_FastPos)
/* we can use ((limit - pos) >> 31) only if (pos < ((UInt32)1 << 31)) */
/*
#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \
#define BSR2_RET(pos, res) { UInt32 zz = 6 + ((kNumLogBits - 1) & \
(0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \
res = p->g_FastPos[pos >> i] + (i * 2); }
res = p->g_FastPos[pos >> zz] + (zz * 2); }
*/
/*
#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \
#define BSR2_RET(pos, res) { UInt32 zz = 6 + ((kNumLogBits - 1) & \
(0 - (((((UInt32)1 << (kNumLogBits)) - 1) - (pos >> 6)) >> 31))); \
res = p->g_FastPos[pos >> i] + (i * 2); }
res = p->g_FastPos[pos >> zz] + (zz * 2); }
*/
#define BSR2_RET(pos, res) { UInt32 i = (pos < (1 << (kNumLogBits + 6))) ? 6 : 6 + kNumLogBits - 1; \
res = p->g_FastPos[pos >> i] + (i * 2); }
#define BSR2_RET(pos, res) { UInt32 zz = (pos < (1 << (kNumLogBits + 6))) ? 6 : 6 + kNumLogBits - 1; \
res = p->g_FastPos[pos >> zz] + (zz * 2); }
/*
#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \
@ -983,12 +983,17 @@ static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
{
UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur;
UInt32 matchPrice, repMatchPrice, normalMatchPrice;
UInt32 lenEnd, cur;
UInt32 reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS];
UInt32 *matches;
{
UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, len;
UInt32 matchPrice, repMatchPrice, normalMatchPrice;
const Byte *data;
Byte curByte, matchByte;
if (p->optimumEndIndex != p->optimumCurrentIndex)
{
const COptimal *opt = &p->opt[p->optimumCurrentIndex];
@ -1176,8 +1181,11 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
}
#endif
}
for (;;)
{
UInt32 numAvail;
UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen;
UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice;
Bool nextIsChar;
@ -1465,6 +1473,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
for (lenTest = /*2*/ startLen; ; lenTest++)
{
UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN];
{
UInt32 lenToPosState = GetLenToPosState(lenTest);
COptimal *opt;
if (curBack < kNumFullDistances)
@ -1480,6 +1489,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
opt->backPrev = curBack + LZMA_NUM_REPS;
opt->prev1IsChar = False;
}
}
if (/*_maxMode && */lenTest == matches[offs])
{
@ -1509,15 +1519,15 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
/* for (; lenTest2 >= 2; lenTest2--) */
{
UInt32 offset = cur + lenTest + 1 + lenTest2;
UInt32 curAndLenPrice;
UInt32 curAndLenPrice2;
COptimal *opt;
while (lenEnd < offset)
p->opt[++lenEnd].price = kInfinityPrice;
curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
curAndLenPrice2 = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
opt = &p->opt[offset];
if (curAndLenPrice < opt->price)
if (curAndLenPrice2 < opt->price)
{
opt->price = curAndLenPrice;
opt->price = curAndLenPrice2;
opt->posPrev = cur + lenTest + 1;
opt->backPrev = 0;
opt->prev1IsChar = True;
@ -1718,7 +1728,6 @@ static void FillDistancesPrices(CLzmaEnc *p)
{
UInt32 *distancesPrices = p->distancesPrices[lenToPosState];
UInt32 i;
for (i = 0; i < kStartPosModelIndex; i++)
distancesPrices[i] = posSlotPrices[i];
for (; i < kNumFullDistances; i++)

View File

@ -1,5 +1,5 @@
/* Ppmd.h -- PPMD codec common code
2013-01-18 : Igor Pavlov : Public domain
2016-05-16 : Igor Pavlov : Public domain
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
#ifndef __PPMD_H
@ -77,8 +77,8 @@ typedef
CPpmd_Byte_Ref;
#define PPMD_SetAllBitsIn256Bytes(p) \
{ unsigned i; for (i = 0; i < 256 / sizeof(p[0]); i += 8) { \
p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }}
{ unsigned z; for (z = 0; z < 256 / sizeof(p[0]); z += 8) { \
p[z+7] = p[z+6] = p[z+5] = p[z+4] = p[z+3] = p[z+2] = p[z+1] = p[z+0] = ~(size_t)0; }}
EXTERN_C_END

View File

@ -1,5 +1,5 @@
/* Ppmd7.c -- PPMdH codec
2015-09-28 : Igor Pavlov : Public domain
2016-05-21 : Igor Pavlov : Public domain
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
#include "Precomp.h"
@ -639,10 +639,10 @@ CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *escFreq)
unsigned nonMasked = p->MinContext->NumStats - numMasked;
if (p->MinContext->NumStats != 256)
{
see = p->See[p->NS2Indx[nonMasked - 1]] +
see = p->See[(unsigned)p->NS2Indx[nonMasked - 1]] +
(nonMasked < (unsigned)SUFFIX(p->MinContext)->NumStats - p->MinContext->NumStats) +
2 * (p->MinContext->SummFreq < 11 * p->MinContext->NumStats) +
4 * (numMasked > nonMasked) +
2 * (unsigned)(p->MinContext->SummFreq < 11 * p->MinContext->NumStats) +
4 * (unsigned)(numMasked > nonMasked) +
p->HiBitsFlag;
{
unsigned r = (see->Summ >> see->Shift);

View File

@ -1,5 +1,5 @@
/* Ppmd7.h -- PPMdH compression codec
2010-03-12 : Igor Pavlov : Public domain
2016-05-21 : Igor Pavlov : Public domain
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
/* This code supports virtual RangeDecoder and includes the implementation
@ -86,10 +86,10 @@ void Ppmd7_Update2(CPpmd7 *p);
void Ppmd7_UpdateBin(CPpmd7 *p);
#define Ppmd7_GetBinSumm(p) \
&p->BinSumm[Ppmd7Context_OneState(p->MinContext)->Freq - 1][p->PrevSuccess + \
&p->BinSumm[(unsigned)Ppmd7Context_OneState(p->MinContext)->Freq - 1][p->PrevSuccess + \
p->NS2BSIndx[Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] + \
(p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]) + \
2 * p->HB2Flag[Ppmd7Context_OneState(p->MinContext)->Symbol] + \
2 * p->HB2Flag[(unsigned)Ppmd7Context_OneState(p->MinContext)->Symbol] + \
((p->RunLength >> 26) & 0x20)]
CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale);

View File

@ -1,5 +1,5 @@
/* 7zMain.c - Test application for 7z Decoder
2015-08-02 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@ -310,10 +310,10 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nt, char *s)
ms[1] = 29;
for (mon = 0;; mon++)
{
unsigned s = ms[mon];
if (v < s)
unsigned d = ms[mon];
if (v < d)
break;
v -= s;
v -= d;
}
s = UIntToStr(s, year, 4); *s++ = '-';
UIntToStr_2(s, mon + 1); s[2] = '-'; s += 3;

View File

@ -1,5 +1,5 @@
/* SfxSetup.c - 7z SFX Setup
2015-11-08 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@ -20,6 +20,7 @@
#include "../../7zCrc.h"
#include "../../7zFile.h"
#include "../../CpuArch.h"
#include "../../DllSecur.h"
#define k_EXE_ExtIndex 2
@ -254,6 +255,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
Bool useShellExecute = True;
DWORD exitCode = 0;
LoadSecurityDlls();
#ifdef _CONSOLE
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
#else
@ -396,11 +399,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
{
size_t offset = 0;
size_t outSizeProcessed = 0;
size_t len;
WCHAR *temp;
len = SzArEx_GetFileNameUtf16(&db, i, NULL);
if (len >= MAX_PATH)
if (SzArEx_GetFileNameUtf16(&db, i, NULL) >= MAX_PATH)
{
res = SZ_ERROR_FAIL;
break;

View File

@ -187,6 +187,14 @@ SOURCE=..\..\Delta.h
# End Source File
# Begin Source File
SOURCE=..\..\DllSecur.c
# End Source File
# Begin Source File
SOURCE=..\..\DllSecur.h
# End Source File
# Begin Source File
SOURCE=..\..\Lzma2Dec.c
# End Source File
# Begin Source File

View File

@ -16,6 +16,7 @@ C_OBJS = \
$O\BraIA64.obj \
$O\CpuArch.obj \
$O\Delta.obj \
$O\DllSecur.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \

View File

@ -17,6 +17,7 @@ C_OBJS = \
$O\BraIA64.obj \
$O\CpuArch.obj \
$O\Delta.obj \
$O\DllSecur.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \

View File

@ -404,11 +404,11 @@ HRESULT CDecoder::Decode(
len = password.Len();
}
CByteBuffer buffer(len * 2);
for (size_t i = 0; i < len; i++)
for (size_t k = 0; k < len; k++)
{
wchar_t c = passwordBSTR[i];
((Byte *)buffer)[i * 2] = (Byte)c;
((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
wchar_t c = passwordBSTR[k];
((Byte *)buffer)[k * 2] = (Byte)c;
((Byte *)buffer)[k * 2 + 1] = (Byte)(c >> 8);
}
RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, (UInt32)buffer.Size()));
}

View File

@ -148,9 +148,9 @@ HRESULT CEncoder::CreateMixerCoder(
RINOK(_mixer->SetBindInfo(_bindInfo));
FOR_VECTOR (i, _options.Methods)
FOR_VECTOR (m, _options.Methods)
{
const CMethodFull &methodFull = _options.Methods[i];
const CMethodFull &methodFull = _options.Methods[m];
CCreatedCoder cod;
@ -410,9 +410,9 @@ HRESULT CEncoder::Encode(
mtOutStreamNotifySpec->_stream = outStream;
mtOutStreamNotifySpec->_mtProgresSpec = mtProgressSpec;
FOR_VECTOR(i, tempBufferSpecs)
FOR_VECTOR(t, tempBufferSpecs)
{
tempBufferSpecs[i]->_mtProgresSpec = mtProgressSpec;
tempBufferSpecs[t]->_mtProgresSpec = mtProgressSpec;
}
}
@ -591,9 +591,9 @@ HRESULT CEncoder::EncoderConstr()
continue;
}
int i = _bindInfo.FindStream_in_PackStreams(outIndex);
if (i >= 0)
_bindInfo.PackStreams.MoveToFront(i);
int si = _bindInfo.FindStream_in_PackStreams(outIndex);
if (si >= 0)
_bindInfo.PackStreams.MoveToFront(si);
break;
}
}

View File

@ -319,13 +319,15 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
curUnpacked += _db.Files[k].Size;
}
HRESULT result = folderOutStream->Init(fileIndex,
allFilesMode ? NULL : indices + i,
numSolidFiles);
{
HRESULT result = folderOutStream->Init(fileIndex,
allFilesMode ? NULL : indices + i,
numSolidFiles);
i += numSolidFiles;
i += numSolidFiles;
RINOK(result);
RINOK(result);
}
// to test solid block with zero unpacked size we disable that code
if (folderOutStream->WasWritingFinished())

View File

@ -429,11 +429,11 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
name = "LZMA2";
if (propsSize == 1)
{
Byte p = props[0];
if ((p & 1) == 0)
ConvertUInt32ToString((UInt32)((p >> 1) + 12), s);
Byte d = props[0];
if ((d & 1) == 0)
ConvertUInt32ToString((UInt32)((d >> 1) + 12), s);
else
GetStringForSizeValue(s, 3 << ((p >> 1) + 11));
GetStringForSizeValue(s, 3 << ((d >> 1) + 11));
}
}
else if (id == k_PPMD)

View File

@ -675,14 +675,16 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
static HRESULT ParseBond(UString &srcString, UInt32 &coder, UInt32 &stream)
{
stream = 0;
int index = ParseStringToUInt32(srcString, coder);
if (index == 0)
return E_INVALIDARG;
srcString.DeleteFrontal(index);
{
unsigned index = ParseStringToUInt32(srcString, coder);
if (index == 0)
return E_INVALIDARG;
srcString.DeleteFrontal(index);
}
if (srcString[0] == 's')
{
srcString.Delete(0);
int index = ParseStringToUInt32(srcString, stream);
unsigned index = ParseStringToUInt32(srcString, stream);
if (index == 0)
return E_INVALIDARG;
srcString.DeleteFrontal(index);

View File

@ -1097,7 +1097,10 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
if (CrcCalc(data, unpackSize) != folders.FolderCRCs.Vals[i])
ThrowIncorrect();
}
HeadersSize += folders.PackPositions[folders.NumPackStreams];
if (folders.PackPositions)
HeadersSize += folders.PackPositions[folders.NumPackStreams];
return S_OK;
}
@ -1150,9 +1153,8 @@ HRESULT CInArchive::ReadHeader(
if (type == NID::kFilesInfo)
{
CNum numFiles = ReadNum();
const CNum numFiles = ReadNum();
db.Files.ClearAndSetSize(numFiles);
CNum i;
/*
db.Files.Reserve(numFiles);
CNum i;
@ -1174,8 +1176,8 @@ HRESULT CInArchive::ReadHeader(
for (;;)
{
UInt64 type = ReadID();
if (type == NID::kEnd)
const UInt64 type2 = ReadID();
if (type2 == NID::kEnd)
break;
UInt64 size = ReadNumber();
if (size > _inByteBack->GetRem())
@ -1184,9 +1186,9 @@ HRESULT CInArchive::ReadHeader(
switchProp.Set(this, _inByteBack->GetPtr(), (size_t)size, true);
bool addPropIdToList = true;
bool isKnownType = true;
if (type > ((UInt32)1 << 30))
if (type2 > ((UInt32)1 << 30))
isKnownType = false;
else switch ((UInt32)type)
else switch ((UInt32)type2)
{
case NID::kName:
{
@ -1220,7 +1222,7 @@ HRESULT CInArchive::ReadHeader(
ReadBoolVector2(db.Files.Size(), boolVector);
CStreamSwitch streamSwitch;
streamSwitch.Set(this, &dataVector);
for (i = 0; i < numFiles; i++)
for (CNum i = 0; i < numFiles; i++)
{
CFileItem &file = db.Files[i];
file.AttribDefined = boolVector[i];
@ -1263,7 +1265,7 @@ HRESULT CInArchive::ReadHeader(
{
ReadBoolVector(numFiles, emptyStreamVector);
numEmptyStreams = 0;
for (i = 0; i < (CNum)emptyStreamVector.Size(); i++)
for (CNum i = 0; i < (CNum)emptyStreamVector.Size(); i++)
if (emptyStreamVector[i])
numEmptyStreams++;
@ -1337,7 +1339,7 @@ HRESULT CInArchive::ReadHeader(
if (isKnownType)
{
if (addPropIdToList)
db.ArcInfo.FileInfoPopIDs.Add(type);
db.ArcInfo.FileInfoPopIDs.Add(type2);
}
else
{
@ -1358,6 +1360,9 @@ HRESULT CInArchive::ReadHeader(
CNum sizeIndex = 0;
CNum numAntiItems = 0;
CNum i;
for (i = 0; i < numEmptyStreams; i++)
if (antiFileVector[i])
numAntiItems++;

View File

@ -540,13 +540,13 @@ void COutArchive::WriteHeader(
*/
_useAlign = true;
unsigned i;
UInt64 packedSize = 0;
for (i = 0; i < db.PackSizes.Size(); i++)
packedSize += db.PackSizes[i];
{
UInt64 packSize = 0;
FOR_VECTOR (i, db.PackSizes)
packSize += db.PackSizes[i];
headerOffset = packSize;
}
headerOffset = packedSize;
WriteByte(NID::kHeader);
@ -560,7 +560,7 @@ void COutArchive::WriteHeader(
CRecordVector<UInt64> unpackSizes;
CUInt32DefVector digests;
for (i = 0; i < db.Files.Size(); i++)
FOR_VECTOR (i, db.Files)
{
const CFileItem &file = db.Files[i];
if (!file.HasStream)
@ -588,14 +588,17 @@ void COutArchive::WriteHeader(
CBoolVector emptyStreamVector;
emptyStreamVector.ClearAndSetSize(db.Files.Size());
unsigned numEmptyStreams = 0;
for (i = 0; i < db.Files.Size(); i++)
if (db.Files[i].HasStream)
emptyStreamVector[i] = false;
else
{
emptyStreamVector[i] = true;
numEmptyStreams++;
}
{
FOR_VECTOR (i, db.Files)
if (db.Files[i].HasStream)
emptyStreamVector[i] = false;
else
{
emptyStreamVector[i] = true;
numEmptyStreams++;
}
}
if (numEmptyStreams != 0)
{
WritePropBoolVector(NID::kEmptyStream, emptyStreamVector);
@ -605,7 +608,8 @@ void COutArchive::WriteHeader(
antiVector.ClearAndSetSize(numEmptyStreams);
bool thereAreEmptyFiles = false, thereAreAntiItems = false;
unsigned cur = 0;
for (i = 0; i < db.Files.Size(); i++)
FOR_VECTOR (i, db.Files)
{
const CFileItem &file = db.Files[i];
if (file.HasStream)
@ -672,17 +676,21 @@ void COutArchive::WriteHeader(
CBoolVector boolVector;
boolVector.ClearAndSetSize(db.Files.Size());
unsigned numDefined = 0;
for (i = 0; i < db.Files.Size(); i++)
{
bool defined = db.Files[i].AttribDefined;
boolVector[i] = defined;
if (defined)
numDefined++;
FOR_VECTOR (i, db.Files)
{
bool defined = db.Files[i].AttribDefined;
boolVector[i] = defined;
if (defined)
numDefined++;
}
}
if (numDefined != 0)
{
WriteAlignedBoolHeader(boolVector, numDefined, NID::kWinAttrib, 4);
for (i = 0; i < db.Files.Size(); i++)
FOR_VECTOR (i, db.Files)
{
const CFileItem &file = db.Files[i];
if (file.AttribDefined)

View File

@ -38,7 +38,7 @@ struct CFilterMode
{
if (Id == k_IA64)
Delta = 16;
else if (Id == k_ARM || Id == k_PPC || Id == k_PPC)
else if (Id == k_ARM || Id == k_PPC || Id == k_SPARC)
Delta = 4;
else if (Id == k_ARMT)
Delta = 2;
@ -779,7 +779,7 @@ struct CSolidGroup
CRecordVector<CFolderRepack> folderRefs;
};
static const char *g_ExeExts[] =
static const char * const g_ExeExts[] =
{
"dll"
, "exe"
@ -1681,17 +1681,18 @@ HRESULT Update(
}
UInt64 inSizeForReduce = 0;
unsigned i;
for (i = 0; i < updateItems.Size(); i++)
{
const CUpdateItem &ui = updateItems[i];
if (ui.NewData)
FOR_VECTOR (i, updateItems)
{
complexity += ui.Size;
if (numSolidFiles != 1)
inSizeForReduce += ui.Size;
else if (inSizeForReduce < ui.Size)
inSizeForReduce = ui.Size;
const CUpdateItem &ui = updateItems[i];
if (ui.NewData)
{
complexity += ui.Size;
if (numSolidFiles != 1)
inSizeForReduce += ui.Size;
else if (inSizeForReduce < ui.Size)
inSizeForReduce = ui.Size;
}
}
}
@ -1753,7 +1754,7 @@ HRESULT Update(
const CCompressionMethodMode &method = *options.Method;
for (i = 0; i < updateItems.Size(); i++)
FOR_VECTOR (i, updateItems)
{
const CUpdateItem &ui = updateItems[i];
if (!ui.NewData || !ui.HasStream())
@ -1857,6 +1858,8 @@ HRESULT Update(
/* ---------- Write non-AUX dirs and Empty files ---------- */
CUIntVector emptyRefs;
unsigned i;
for (i = 0; i < updateItems.Size(); i++)
{
const CUpdateItem &ui = updateItems[i];
@ -1919,7 +1922,8 @@ HRESULT Update(
const CFilterMode2 &filterMode = filters[groupIndex];
CCompressionMethodMode method = *options.Method;
HRESULT res = MakeExeMethod(method, filterMode,
{
HRESULT res = MakeExeMethod(method, filterMode,
#ifdef _7ZIP_ST
false
#else
@ -1927,7 +1931,8 @@ HRESULT Update(
#endif
);
RINOK(res);
RINOK(res);
}
if (filterMode.Encrypted)
{
@ -2266,8 +2271,12 @@ HRESULT Update(
CRecordVector<CRefItem> refItems;
refItems.ClearAndSetSize(numFiles);
bool sortByType = (options.UseTypeSorting && numSolidFiles > 1);
unsigned i;
for (i = 0; i < numFiles; i++)
refItems[i] = CRefItem(group.Indices[i], updateItems[group.Indices[i]], sortByType);
CSortParam sortParam;
// sortParam.TreeFolders = &treeFolders;
sortParam.SortByType = sortByType;

View File

@ -81,7 +81,7 @@ HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIAN
}
UInt32 number;
int index = ParseStringToUInt32(name, number);
unsigned index = ParseStringToUInt32(name, number);
UString realName = name.Ptr(index);
if (index == 0)
{

View File

@ -203,7 +203,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
_streams.Add(stream);
{
UInt64 numFiles = _streams.Size();
const UInt64 numFiles = _streams.Size();
RINOK(callback->SetCompleted(&numFiles, NULL));
}
@ -218,7 +218,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
break;
if (result != S_OK)
return result;
if (!stream)
if (!nextStream)
break;
{
/*
@ -228,14 +228,14 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
return E_INVALIDARG;
size = prop.uhVal.QuadPart;
*/
RINOK(stream->Seek(0, STREAM_SEEK_END, &size));
RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
RINOK(nextStream->Seek(0, STREAM_SEEK_END, &size));
RINOK(nextStream->Seek(0, STREAM_SEEK_SET, NULL));
}
_totalSize += size;
_sizes.Add(size);
_streams.Add(nextStream);
{
UInt64 numFiles = _streams.Size();
const UInt64 numFiles = _streams.Size();
RINOK(callback->SetCompleted(&numFiles, NULL));
}
}

View File

@ -749,11 +749,10 @@ static int main2(int numArgs, const char *args[])
}
}
if (!stdOutMode)
Print_Size("Output size: ", outStreamSpec->ProcessedSize);
if (outStreamSpec)
{
if (!stdOutMode)
Print_Size("Output size: ", outStreamSpec->ProcessedSize);
if (outStreamSpec->Close() != S_OK)
throw "File closing error";
}

View File

@ -804,6 +804,15 @@ SOURCE=..\..\..\..\C\Delta.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\DllSecur.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\DllSecur.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Lzma2Dec.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File

View File

@ -24,6 +24,8 @@
#include "../../MyVersion.h"
#include "../../../../C/DllSecur.h"
using namespace NWindows;
using namespace NFile;
using namespace NDir;
@ -103,7 +105,7 @@ static const wchar_t *kUniversalWildcard = L"*";
static const int kCommandIndex = 0;
static const char *kHelpString =
"\nUsage: 7zSFX [<command>] [<switches>...]\n"
"\nUsage: 7zSFX [<command>] [<switches>...] [<file_name>...]\n"
"\n"
"<Commands>\n"
// " l: List contents of archive\n"
@ -222,13 +224,6 @@ void AddCommandLineWildcardToCensor(NWildcard::CCensor &wildcardCensor,
ShowMessageAndThrowException(kIncorrectWildcardInCommandLine, NExitCode::kUserError);
}
void AddToCensorFromNonSwitchesStrings(NWildcard::CCensor &wildcardCensor,
const UStringVector & /* nonSwitchStrings */, NRecursedType::EEnum type,
bool /* thereAreSwitchIncludeWildcards */)
{
AddCommandLineWildcardToCensor(wildcardCensor, kUniversalWildcard, true, type);
}
#ifndef _WIN32
static void GetArguments(int numArgs, const char *args[], UStringVector &parts)
@ -248,6 +243,11 @@ int Main2(
#endif
)
{
#ifdef _WIN32
// do we need load Security DLLs for console program?
LoadSecurityDlls();
#endif
#if defined(_WIN32) && !defined(UNDER_CE)
SetFileApisToOEM();
#endif
@ -283,9 +283,16 @@ int Main2(
commandStrings.Delete(0);
NCommandLineParser::CParser parser(kNumSwitches);
try
{
parser.ParseStrings(kSwitchForms, commandStrings);
if (!parser.ParseStrings(kSwitchForms, commandStrings))
{
g_StdOut << "Command line error:" << endl
<< parser.ErrorMessage << endl
<< parser.ErrorLine << endl;
return NExitCode::kUserError;
}
}
catch(...)
{
@ -297,19 +304,23 @@ int Main2(
PrintHelp();
return 0;
}
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
int numNonSwitchStrings = nonSwitchStrings.Size();
unsigned curCommandIndex = 0;
CArchiveCommand command;
if (numNonSwitchStrings == 0)
if (nonSwitchStrings.IsEmpty())
command.CommandType = NCommandType::kFullExtract;
else
{
if (numNonSwitchStrings > 1)
PrintHelpAndExit();
if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], command))
PrintHelpAndExit();
const UString &cmd = nonSwitchStrings[curCommandIndex];
if (!ParseArchiveCommand(cmd, command))
{
g_StdOut << "ERROR: Unknown command:" << endl << cmd << endl;
return NExitCode::kUserError;
}
curCommandIndex = 1;
}
@ -318,11 +329,17 @@ int Main2(
NWildcard::CCensor wildcardCensor;
bool thereAreSwitchIncludeWildcards;
thereAreSwitchIncludeWildcards = false;
AddToCensorFromNonSwitchesStrings(wildcardCensor, nonSwitchStrings, recursedType,
thereAreSwitchIncludeWildcards);
{
if (nonSwitchStrings.Size() == curCommandIndex)
AddCommandLineWildcardToCensor(wildcardCensor, kUniversalWildcard, true, recursedType);
for (; curCommandIndex < nonSwitchStrings.Size(); curCommandIndex++)
{
const UString &s = nonSwitchStrings[curCommandIndex];
if (s.IsEmpty())
throw "Empty file path";
AddCommandLineWildcardToCensor(wildcardCensor, s, true, recursedType);
}
}
bool yesToAll = parser[NKey::kYes].ThereIs;
@ -363,9 +380,11 @@ int Main2(
IUnknown
#endif
> compressCodecsInfo = codecs;
HRESULT result = codecs->Load();
if (result != S_OK)
throw CSystemException(result);
{
HRESULT result = codecs->Load();
if (result != S_OK)
throw CSystemException(result);
}
if (command.CommandType != NCommandType::kList)
{

View File

@ -4,6 +4,7 @@ CFLAGS = $(CFLAGS) \
-DEXTRACT_ONLY \
-DNO_READ_FROM_CODER \
-D_SFX \
-D_CONSOLE \
CURRENT_OBJS = \
$O\SfxCon.obj \
@ -114,6 +115,7 @@ C_OBJS = \
$O\BraIA64.obj \
$O\CpuArch.obj \
$O\Delta.obj \
$O\DllSecur.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \
$O\Ppmd7.obj \

View File

@ -55,8 +55,7 @@ struct CThreadExtracting
Result = ArchiveLink.Open2(options, ExtractCallbackSpec);
if (Result != S_OK)
{
if (Result != S_OK)
ErrorMessage = kCantOpenArchive;
ErrorMessage = kCantOpenArchive;
return;
}

View File

@ -706,6 +706,15 @@ SOURCE=..\..\..\..\C\Delta.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\DllSecur.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\DllSecur.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Lzma2Dec.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File

View File

@ -23,6 +23,8 @@
#include "ExtractEngine.h"
#include "../../../../C/DllSecur.h"
#include "resource.h"
using namespace NWindows;
@ -135,6 +137,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
NT_CHECK
#ifdef _WIN32
LoadSecurityDlls();
#endif
// InitCommonControls();
UString archiveName, switches;
@ -207,11 +213,13 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
CCodecs *codecs = new CCodecs;
CMyComPtr<IUnknown> compressCodecsInfo = codecs;
HRESULT result = codecs->Load();
if (result != S_OK)
{
ShowErrorMessage(L"Can not load codecs");
return 1;
HRESULT result = codecs->Load();
if (result != S_OK)
{
ShowErrorMessage(L"Can not load codecs");
return 1;
}
}
const FString tempDirPath = tempDir.GetPath();

View File

@ -100,6 +100,7 @@ C_OBJS = \
$O\BraIA64.obj \
$O\CpuArch.obj \
$O\Delta.obj \
$O\DllSecur.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \
$O\Threads.obj \

View File

@ -888,6 +888,15 @@ SOURCE=..\..\..\..\C\Delta.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\DllSecur.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\DllSecur.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Lzma2Dec.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File

View File

@ -28,6 +28,8 @@
#include "../../UI/GUI/ExtractGUI.h"
#include "../../UI/GUI/ExtractRes.h"
#include "../../../../C/DllSecur.h"
using namespace NWindows;
using namespace NFile;
using namespace NDir;
@ -220,6 +222,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
try
{
#ifdef _WIN32
LoadSecurityDlls();
#endif
return WinMain2();
}
catch(const CNewException &)

View File

@ -131,8 +131,9 @@ C_OBJS = \
$O\Bra.obj \
$O\Bra86.obj \
$O\BraIA64.obj \
$O\Delta.obj \
$O\CpuArch.obj \
$O\Delta.obj \
$O\DllSecur.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \
$O\Ppmd7.obj \

View File

@ -403,9 +403,9 @@ HRESULT CMethodProps::ParseParamsFromPROPVARIANT(const UString &realName, const
if (value.vt == VT_EMPTY)
{
// {realName}=[empty]
UString name, value;
SplitParam(realName, name, value);
return SetParam(name, value);
UString name, valueStr;
SplitParam(realName, name, valueStr);
return SetParam(name, valueStr);
}
// {realName}=value

View File

@ -514,13 +514,13 @@ HRESULT CDecoder::Code(ISequentialInStream * const *inStreams, const UInt64 * co
STDMETHODIMP CDecoder::SetInStream2(UInt32 streamIndex, ISequentialInStream *inStream)
{
inStreams[streamIndex] = inStream;
_inStreams[streamIndex] = inStream;
return S_OK;
}
STDMETHODIMP CDecoder::ReleaseInStream2(UInt32 streamIndex)
{
inStreams[streamIndex].Release();
_inStreams[streamIndex].Release();
return S_OK;
}
@ -601,7 +601,7 @@ STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
do
{
UInt32 curSize = _bufsCurSizes[dec.state] - (UInt32)totalRead;
HRESULT res2 = inStreams[dec.state]->Read(_bufs[dec.state] + totalRead, curSize, &curSize);
HRESULT res2 = _inStreams[dec.state]->Read(_bufs[dec.state] + totalRead, curSize, &curSize);
_readRes[dec.state] = res2;
if (curSize == 0)
break;

View File

@ -72,7 +72,7 @@ class CDecoder:
unsigned _extraReadSizes[BCJ2_NUM_STREAMS];
UInt64 _inStreamsProcessed[BCJ2_NUM_STREAMS];
HRESULT _readRes[BCJ2_NUM_STREAMS];
CMyComPtr<ISequentialInStream> inStreams[BCJ2_NUM_STREAMS];
CMyComPtr<ISequentialInStream> _inStreams[BCJ2_NUM_STREAMS];
bool _finishMode;
bool _outSizeDefined;

View File

@ -387,7 +387,7 @@ static void AddRenamePair(CObjectVector<CRenamePair> *renamePairs,
val.Add_LF();
if (type == NRecursedType::kRecursed)
val.AddAscii("-r");
else if (type == NRecursedType::kRecursed)
else if (type == NRecursedType::kWildcardOnlyRecursed)
val.AddAscii("-r0");
throw CArcCmdLineException("Unsupported rename command:", val);
}

View File

@ -1046,8 +1046,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
if (_item.IsAltStream && _item.ParentIndex != (UInt32)(Int32)-1)
{
CIndexToPathPair pair(_item.ParentIndex);
int renIndex = _renamedFiles.FindInSorted(pair);
int renIndex = _renamedFiles.FindInSorted(CIndexToPathPair(_item.ParentIndex));
if (renIndex >= 0)
{
const CIndexToPathPair &pair = _renamedFiles[renIndex];
@ -1319,7 +1318,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
if (needWriteFile)
{
_outFileStreamSpec = new COutFileStream;
CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
CMyComPtr<ISequentialOutStream> outStreamLoc2(_outFileStreamSpec);
if (!_outFileStreamSpec->Open(fullProcessedPath, _isSplit ? OPEN_ALWAYS: CREATE_ALWAYS))
{
// if (::GetLastError() != ERROR_FILE_EXISTS || !isSplit)
@ -1346,7 +1345,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
RINOK(_outFileStreamSpec->Seek(_position, STREAM_SEEK_SET, NULL));
}
_outFileStream = outStreamLoc;
_outFileStream = outStreamLoc2;
}
}
}

View File

@ -866,11 +866,10 @@ HRESULT CEncoderInfo::Init(
outStreamSpec = new CBenchmarkOutStream;
outStream = outStreamSpec;
if (!outStreamSpec->Alloc(kCompressedBufferSize))
return E_OUTOFMEMORY;
outStream = outStreamSpec;
propStreamSpec = 0;
if (!propStream)
{
@ -917,15 +916,8 @@ HRESULT CEncoderInfo::Init(
// we must call encoding one time to calculate password key for key cache.
// it must be after WriteCoderProperties!
CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
Byte temp[16];
memset(temp, 0, sizeof(temp));
inStreamSpec->Init(temp, sizeof(temp));
CCrcOutStream *outStreamSpec = new CCrcOutStream;
CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
outStreamSpec->Init();
if (_encoderFilter)
{
@ -934,7 +926,15 @@ HRESULT CEncoderInfo::Init(
}
else
{
RINOK(_encoder->Code(inStream, outStream, 0, 0, NULL));
CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
inStreamSpec->Init(temp, sizeof(temp));
CCrcOutStream *crcStreamSpec = new CCrcOutStream;
CMyComPtr<ISequentialOutStream> crcStream = crcStreamSpec;
crcStreamSpec->Init();
RINOK(_encoder->Code(inStream, crcStream, 0, 0, NULL));
}
}
}
@ -1740,10 +1740,10 @@ struct CTotalBenchRes
}
};
static void PrintNumber(IBenchPrintCallback &f, UInt64 value, int size)
static void PrintNumber(IBenchPrintCallback &f, UInt64 value, unsigned size)
{
char s[128];
int startPos = (int)sizeof(s) - 32;
unsigned startPos = (unsigned)sizeof(s) - 32;
memset(s, ' ', startPos);
ConvertUInt64ToString(value, s + startPos);
// if (withSpace)
@ -1751,7 +1751,7 @@ static void PrintNumber(IBenchPrintCallback &f, UInt64 value, int size)
startPos--;
size++;
}
int len = (int)strlen(s + startPos);
unsigned len = (unsigned)strlen(s + startPos);
if (size > len)
{
startPos -= (size - len);
@ -1761,26 +1761,26 @@ static void PrintNumber(IBenchPrintCallback &f, UInt64 value, int size)
f.Print(s + startPos);
}
static const int kFieldSize_Name = 12;
static const int kFieldSize_SmallName = 4;
static const int kFieldSize_Speed = 9;
static const int kFieldSize_Usage = 5;
static const int kFieldSize_RU = 6;
static const int kFieldSize_Rating = 6;
static const int kFieldSize_EU = 5;
static const int kFieldSize_Effec = 5;
static const unsigned kFieldSize_Name = 12;
static const unsigned kFieldSize_SmallName = 4;
static const unsigned kFieldSize_Speed = 9;
static const unsigned kFieldSize_Usage = 5;
static const unsigned kFieldSize_RU = 6;
static const unsigned kFieldSize_Rating = 6;
static const unsigned kFieldSize_EU = 5;
static const unsigned kFieldSize_Effec = 5;
static const int kFieldSize_TotalSize = 4 + kFieldSize_Speed + kFieldSize_Usage + kFieldSize_RU + kFieldSize_Rating;
static const int kFieldSize_EUAndEffec = 2 + kFieldSize_EU + kFieldSize_Effec;
static const unsigned kFieldSize_TotalSize = 4 + kFieldSize_Speed + kFieldSize_Usage + kFieldSize_RU + kFieldSize_Rating;
static const unsigned kFieldSize_EUAndEffec = 2 + kFieldSize_EU + kFieldSize_Effec;
static void PrintRating(IBenchPrintCallback &f, UInt64 rating, int size)
static void PrintRating(IBenchPrintCallback &f, UInt64 rating, unsigned size)
{
PrintNumber(f, (rating + 500000) / 1000000, size);
}
static void PrintPercents(IBenchPrintCallback &f, UInt64 val, UInt64 divider, int size)
static void PrintPercents(IBenchPrintCallback &f, UInt64 val, UInt64 divider, unsigned size)
{
PrintNumber(f, (val * 100 + divider / 2) / divider, size);
}
@ -1882,7 +1882,7 @@ struct CBenchCallbackToPrint: public IBenchCallback
UInt32 DictSize;
bool Use2Columns;
int NameFieldSize;
unsigned NameFieldSize;
bool ShowFreq;
UInt64 CpuFreq;
@ -2390,10 +2390,10 @@ static void x86cpuid_to_String(const Cx86cpuid &c, AString &s)
{
for (int i = 0; i < 3; i++)
{
UInt32 c[4] = { 0 };
MyCPUID(0x80000002 + i, &c[0], &c[1], &c[2], &c[3]);
UInt32 d[4] = { 0 };
MyCPUID(0x80000002 + i, &d[0], &d[1], &d[2], &d[3]);
for (int j = 0; j < 4; j++)
PrintCpuChars(s, c[j]);
PrintCpuChars(s, d[j]);
}
}
@ -2469,10 +2469,11 @@ HRESULT Bench(
bool multiThreadTests = false;
COneMethodInfo method;
unsigned i;
CBenchBuffer fileDataBuffer;
{
unsigned i;
for (i = 0; i < props.Size(); i++)
{
const CProperty &property = props[i];
@ -2568,6 +2569,7 @@ HRESULT Bench(
RINOK(method.ParseMethodFromPROPVARIANT(name, propVariant));
}
}
if (printCallback)
{
@ -2710,7 +2712,7 @@ HRESULT Bench(
f.NewLine();
f.Print("Size");
const int kFieldSize_CrcSpeed = 6;
const unsigned kFieldSize_CrcSpeed = 6;
unsigned numThreadsTests = 0;
for (;;)
{
@ -2873,7 +2875,7 @@ HRESULT Bench(
showFreq = true;
}
int fileldSize = kFieldSize_TotalSize;
unsigned fileldSize = kFieldSize_TotalSize;
if (showFreq)
fileldSize += kFieldSize_EUAndEffec;
@ -2941,9 +2943,8 @@ HRESULT Bench(
printCallback->NewLine();
HRESULT res;
int freqTest;
const int kNumCpuTests = 3;
for (freqTest = 0; freqTest < kNumCpuTests; freqTest++)
const unsigned kNumCpuTests = 3;
for (unsigned freqTest = 0; freqTest < kNumCpuTests; freqTest++)
{
PrintLeft(f, "CPU", kFieldSize_Name);
UInt32 resVal;
@ -3013,7 +3014,7 @@ HRESULT Bench(
if (needSetComplexity)
callback.BenchProps.SetLzmaCompexity();
for (i = 0; i < numIterations; i++)
for (unsigned i = 0; i < numIterations; i++)
{
const unsigned kStartDicLog = 22;
unsigned pow = (dict < ((UInt32)1 << kStartDicLog)) ? kBenchMinDicLogSize : kStartDicLog;

View File

@ -359,14 +359,11 @@ HRESULT Extract(
op.stream = NULL;
op.filePath = arcPath;
HRESULT result = arcLink.Open3(op, openCallback);
HRESULT result = arcLink.Open_Strict(op, openCallback);
if (result == E_ABORT)
return result;
if (result == S_OK && arcLink.NonOpen_ErrorInfo.ErrorFormatIndex >= 0)
result = S_FALSE;
// arcLink.Set_ErrorsText();
RINOK(extractCallback->OpenResult(codecs, arcLink, arcPath, result));
@ -375,10 +372,10 @@ HRESULT Extract(
thereAreNotOpenArcs = true;
if (!options.StdInMode)
{
NFind::CFileInfo fi;
if (fi.Find(us2fs(arcPath)))
if (!fi.IsDir())
totalPackProcessed += fi.Size;
NFind::CFileInfo fi2;
if (fi2.Find(us2fs(arcPath)))
if (!fi2.IsDir())
totalPackProcessed += fi2.Size;
}
continue;
}

View File

@ -101,8 +101,8 @@ HRESULT CHashBundle::SetMethods(DECL_EXTERNAL_CODECS_LOC_VARS const UStringVecto
h.Hasher = hasher;
h.Name = name;
h.DigestSize = digestSize;
for (unsigned i = 0; i < k_HashCalc_NumGroups; i++)
memset(h.Digests[i], 0, digestSize);
for (unsigned k = 0; k < k_HashCalc_NumGroups; k++)
memset(h.Digests[k], 0, digestSize);
}
return S_OK;

View File

@ -497,7 +497,7 @@ static HRESULT Archive_GetArcProp_UInt(IInArchive *arc, PROPID propid, UInt64 &r
switch (prop.vt)
{
case VT_UI4: result = prop.ulVal; defined = true; break;
case VT_I4: result = prop.lVal; defined = true; break;
case VT_I4: result = (Int64)prop.lVal; defined = true; break;
case VT_UI8: result = (UInt64)prop.uhVal.QuadPart; defined = true; break;
case VT_I8: result = (UInt64)prop.hVal.QuadPart; defined = true; break;
case VT_EMPTY: break;
@ -582,9 +582,9 @@ HRESULT CArc::GetItemPathToParent(UInt32 index, UInt32 parent, UStringVector &pa
if (prevWasAltStream)
{
{
UString &s = parts[parts.Size() - 2];
s += L':';
s += parts.Back();
UString &s2 = parts[parts.Size() - 2];
s2 += L':';
s2 += parts.Back();
}
parts.DeleteBack();
}
@ -864,7 +864,7 @@ HRESULT CArc::GetItem(UInt32 index, CReadArcItem &item) const
{
item.MainPath.DeleteFrom(colon);
item.AltStreamName = item.Path.Ptr(colon + 1);
item.MainIsDir = (colon == 0 || IsPathSepar(item.Path[colon - 1]));
item.MainIsDir = (colon == 0 || IsPathSepar(item.Path[(unsigned)colon - 1]));
item.IsAltStream = true;
}
}
@ -2015,7 +2015,6 @@ HRESULT CArc::OpenStream2(const COpenOptions &op)
const CArcInfoEx &ai = op.codecs->Formats[formatIndex];
if (ai.FindExtension(extension) >= 0)
{
const CArcInfoEx &ai = op.codecs->Formats[formatIndex];
if (ai.Flags_FindSignature() && searchMarkerInHandler)
return S_FALSE;
}
@ -3467,6 +3466,8 @@ static bool ParseTypeParams(const UString &s, COpenType &type)
bool ParseType(CCodecs &codecs, const UString &s, COpenType &type)
{
int pos2 = s.Find(L':');
{
UString name;
if (pos2 < 0)
{
@ -3501,13 +3502,15 @@ bool ParseType(CCodecs &codecs, const UString &s, COpenType &type)
}
type.FormatIndex = index;
}
for (unsigned i = pos2; i < s.Len();)
{
int next = s.Find(L':', i);
if (next < 0)
next = s.Len();
UString name = s.Mid(i, next - i);
const UString name = s.Mid(i, next - i);
if (name.IsEmpty())
return false;
if (!ParseTypeParams(name, type))

View File

@ -401,6 +401,14 @@ struct CArchiveLink
HRESULT Open2(COpenOptions &options, IOpenCallbackUI *callbackUI);
HRESULT Open3(COpenOptions &options, IOpenCallbackUI *callbackUI);
HRESULT Open_Strict(COpenOptions &options, IOpenCallbackUI *callbackUI)
{
HRESULT result = Open3(options, callbackUI);
if (result == S_OK && NonOpen_ErrorInfo.ErrorFormatIndex >= 0)
result = S_FALSE;
return result;
}
HRESULT ReOpen(COpenOptions &options);
};

View File

@ -251,8 +251,6 @@ STDMETHODIMP COutMultiVolStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *n
STDMETHODIMP COutMultiVolStream::SetSize(UInt64 newSize)
{
if (newSize < 0)
return E_INVALIDARG;
unsigned i = 0;
while (i < Streams.Size())
{
@ -758,15 +756,15 @@ static HRESULT Compress(
return errorInfo.SetFromLastError("cannot open SFX module", options.SfxModule);
CMyComPtr<ISequentialOutStream> sfxOutStream;
COutFileStream *outStreamSpec = NULL;
COutFileStream *outStreamSpec2 = NULL;
if (options.VolumesSizes.Size() == 0)
sfxOutStream = outStream;
else
{
outStreamSpec = new COutFileStream;
sfxOutStream = outStreamSpec;
outStreamSpec2 = new COutFileStream;
sfxOutStream = outStreamSpec2;
FString realPath = us2fs(archivePath.GetFinalPath());
if (!outStreamSpec->Create(realPath, false))
if (!outStreamSpec2->Create(realPath, false))
return errorInfo.SetFromLastError("cannot open file", realPath);
}
@ -778,9 +776,9 @@ static HRESULT Compress(
RINOK(NCompress::CopyStream(sfxStream, sfxOutStream, NULL));
if (outStreamSpec)
if (outStreamSpec2)
{
RINOK(outStreamSpec->Close());
RINOK(outStreamSpec2->Close());
}
}
@ -1060,7 +1058,7 @@ HRESULT UpdateArchive(
!options.SetArcPath(codecs, cmdArcPath2))
return E_NOTIMPL;
}
UString arcPath = options.ArchivePath.GetFinalPath();
const UString arcPath = options.ArchivePath.GetFinalPath();
if (cmdArcPath2.IsEmpty())
{
@ -1088,10 +1086,10 @@ HRESULT UpdateArchive(
return E_NOTIMPL;
if (options.VolumesSizes.Size() > 0)
return E_NOTIMPL;
CObjectVector<COpenType> types;
CObjectVector<COpenType> types2;
// change it.
if (options.MethodMode.Type_Defined)
types.Add(options.MethodMode.Type);
types2.Add(options.MethodMode.Type);
// We need to set Properties to open archive only in some cases (WIM archives).
CIntVector excl;
@ -1100,7 +1098,7 @@ HRESULT UpdateArchive(
op.props = &options.MethodMode.Properties;
#endif
op.codecs = codecs;
op.types = &types;
op.types = &types2;
op.excludedFormats = &excl;
op.stdInMode = false;
op.stream = NULL;
@ -1108,14 +1106,11 @@ HRESULT UpdateArchive(
RINOK(callback->StartOpenArchive(arcPath));
HRESULT result = arcLink.Open3(op, openCallback);
HRESULT result = arcLink.Open_Strict(op, openCallback);
if (result == E_ABORT)
return result;
if (result == S_OK && arcLink.NonOpen_ErrorInfo.ErrorFormatIndex >= 0)
result = S_FALSE;
HRESULT res2 = callback->OpenResult(codecs, arcLink, arcPath, result);
/*
if (result == S_FALSE)
@ -1289,10 +1284,11 @@ HRESULT UpdateArchive(
}
}
unsigned i;
for (i = 0; i < options.Commands.Size(); i++)
unsigned ci;
for (ci = 0; ci < options.Commands.Size(); ci++)
{
CArchivePath &ap = options.Commands[i].ArchivePath;
CArchivePath &ap = options.Commands[ci].ArchivePath;
if (usesTempDir)
{
// Check it
@ -1301,7 +1297,7 @@ HRESULT UpdateArchive(
// ap.TempPrefix = tempDirPrefix;
}
if (!options.StdOutMode &&
(i > 0 || !createTempFile))
(ci > 0 || !createTempFile))
{
const FString path = us2fs(ap.GetFinalPath());
if (NFind::DoesFileOrDirExist(path))
@ -1334,7 +1330,7 @@ HRESULT UpdateArchive(
{
unsigned num = dirItems.Items.Size();
processedItems.Alloc(num);
for (i = 0; i < num; i++)
for (unsigned i = 0; i < num; i++)
processedItems[i] = 0;
}
@ -1348,10 +1344,10 @@ HRESULT UpdateArchive(
#endif
*/
for (i = 0; i < options.Commands.Size(); i++)
for (ci = 0; ci < options.Commands.Size(); ci++)
{
const CArc *arc = thereIsInArchive ? arcLink.GetArc() : NULL;
CUpdateArchiveCommand &command = options.Commands[i];
CUpdateArchiveCommand &command = options.Commands[ci];
UString name;
bool isUpdating;
@ -1363,7 +1359,7 @@ HRESULT UpdateArchive(
else
{
name = command.ArchivePath.GetFinalPath();
isUpdating = (i == 0 && options.UpdateArchiveItself && thereIsInArchive);
isUpdating = (ci == 0 && options.UpdateArchiveItself && thereIsInArchive);
}
RINOK(callback->StartArchive(name, isUpdating))
@ -1455,19 +1451,19 @@ HRESULT UpdateArchive(
{
CArchivePath &ap = options.Commands[i].ArchivePath;
FString finalPath = us2fs(ap.GetFinalPath());
FString arcPath;
if (!MyGetFullPathName(finalPath, arcPath))
FString arcPath2;
if (!MyGetFullPathName(finalPath, arcPath2))
return errorInfo.SetFromLastError("GetFullPathName error", finalPath);
fullPaths.Add(arcPath);
fullPaths.Add(arcPath2);
}
CCurrentDirRestorer curDirRestorer;
for (i = 0; i < fullPaths.Size(); i++)
{
UString arcPath = fs2us(fullPaths[i]);
UString fileName = ExtractFileNameFromPath(arcPath);
AString path = GetAnsiString(arcPath);
UString arcPath2 = fs2us(fullPaths[i]);
UString fileName = ExtractFileNameFromPath(arcPath2);
AString path = GetAnsiString(arcPath2);
AString name = GetAnsiString(fileName);
// Warning!!! MAPISendDocuments function changes Current directory
// fnSend(0, ";", (LPSTR)(LPCSTR)path, (LPSTR)(LPCSTR)name, 0);
@ -1505,6 +1501,8 @@ HRESULT UpdateArchive(
CRecordVector<CRefSortPair> pairs;
FStringVector foldersNames;
unsigned i;
for (i = 0; i < dirItems.Items.Size(); i++)
{
const CDirItem &dirItem = dirItems.Items[i];

View File

@ -219,9 +219,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetRawProp(UInt32 index, PROPID propID, con
return Arc->GetRawProps->GetRawProp(
ArcItems ? (*ArcItems)[up.ArcIndex].IndexInServer : up.ArcIndex,
propID, data, dataSize, propType);
{
const CUpdatePair2 &up = (*UpdatePairs)[index];
/*
if (!up.NewData)
return E_FAIL;

View File

@ -59,7 +59,10 @@ CCtrlHandlerSetter::~CCtrlHandlerSetter()
{
#if !defined(UNDER_CE) && defined(_WIN32)
if (!SetConsoleCtrlHandler(HandlerRoutine, FALSE))
throw "SetConsoleCtrlHandler fails";
{
// warning for throw in destructor.
// throw "SetConsoleCtrlHandler fails";
}
#endif
}

View File

@ -283,7 +283,7 @@ HRESULT CHashCallbackConsole::SetOperationResult(UInt64 fileSize, const CHashBun
return CheckBreak2();
}
static const char *k_DigestTitles[] =
static const char * const k_DigestTitles[] =
{
" : "
, " for data: "

View File

@ -900,10 +900,10 @@ HRESULT Print_OpenArchive_Props(CStdOutStream &so, const CCodecs *codecs, const
RINOK(PrintArcProp(so, archive, kpidPhySize, NULL));
if (er.TailSize != 0)
PrintPropNameAndNumber(so, kpidTailSize, er.TailSize);
UInt32 numProps;
RINOK(archive->GetNumberOfArchiveProperties(&numProps));
{
UInt32 numProps;
RINOK(archive->GetNumberOfArchiveProperties(&numProps));
for (UInt32 j = 0; j < numProps; j++)
{
CMyComBSTR name;
@ -1068,7 +1068,7 @@ HRESULT ListArchives(CCodecs *codecs,
g_StdOut << endl << kListing << arcPath << endl << endl;
}
HRESULT result = arcLink.Open3(options, &openCallback);
HRESULT result = arcLink.Open_Strict(options, &openCallback);
if (result != S_OK)
{
@ -1095,9 +1095,6 @@ HRESULT ListArchives(CCodecs *codecs,
}
{
if (arcLink.NonOpen_ErrorInfo.ErrorFormatIndex >= 0)
numErrors++;
FOR_VECTOR (r, arcLink.Arcs)
{
const CArcErrorInfo &arc = arcLink.Arcs[r].ErrorInfo;

View File

@ -939,8 +939,8 @@ INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread,
CWaitCursor waitCursor;
HANDLE h[] = { thread, _createDialogEvent };
WRes res = WaitForMultipleObjects(ARRAY_SIZE(h), h, FALSE, kCreateDelay);
if (res == WAIT_OBJECT_0 && !Sync.ThereIsMessage())
WRes res2 = WaitForMultipleObjects(ARRAY_SIZE(h), h, FALSE, kCreateDelay);
if (res2 == WAIT_OBJECT_0 && !Sync.ThereIsMessage())
return 0;
}
_title = title;

View File

@ -87,7 +87,7 @@ bool GetTextConfig(const AString &s, CObjectVector<CTextConfigPair> &pairs)
break;
if (c == '\\')
{
char c = s[pos++];
c = s[pos++];
switch (c)
{
case 'n': message += '\n'; break;

View File

@ -484,7 +484,7 @@ unsigned GetNumPrefixParts_if_DrivePath(UStringVector &pathParts)
#endif
static unsigned GetNumPrefixParts(const UStringVector pathParts)
static unsigned GetNumPrefixParts(const UStringVector &pathParts)
{
if (pathParts.IsEmpty())
return 0;

View File

@ -51,7 +51,7 @@ LRESULT CComboBox::GetLBText(int index, UString &s)
return len;
if (len > len2)
len = len2;
s.ReleaseBuf_CalcLen(len);
s.ReleaseBuf_CalcLen((unsigned)len);
return len;
}
AString sa;

View File

@ -130,7 +130,10 @@ WinXP-64 FindFirstFile():
\\Server\ - ERROR_INVALID_NAME
\\Server\Share - ERROR_BAD_NETPATH
\\Server\Share - ERROR_BAD_NET_NAME (Win7)
\\Server\Share - ERROR_BAD_NET_NAME (Win7).
!!! There is problem : Win7 makes some requests for "\\Server\Shar" (look in Procmon),
when we call it for "\\Server\Share"
\\Server\Share\ - ERROR_FILE_NOT_FOUND
\\?\UNC\Server\Share - ERROR_INVALID_NAME
@ -508,11 +511,10 @@ bool CFileInfo::Find(CFSTR path)
#endif
CFindFile finder;
if (finder.FindFirst(path, *this))
return true;
#if defined(_WIN32) && !defined(UNDER_CE)
{
/*
DWORD lastError = GetLastError();
if (lastError == ERROR_FILE_NOT_FOUND
|| lastError == ERROR_BAD_NETPATH // XP64: "\\Server\Share"
@ -520,11 +522,26 @@ bool CFileInfo::Find(CFSTR path)
|| lastError == ERROR_INVALID_NAME // XP64: "\\?\UNC\Server\Share"
|| lastError == ERROR_BAD_PATHNAME // Win7: "\\?\UNC\Server\Share"
)
*/
unsigned rootSize = 0;
if (IsSuperPath(path))
rootSize = kSuperPathPrefixSize;
if (NName::IsDrivePath(path + rootSize) && path[rootSize + 3] == 0)
{
unsigned rootSize = 0;
if (IsSuperPath(path))
rootSize = kSuperPathPrefixSize;
if (IS_PATH_SEPAR(path[0]) && path[1] == 0)
DWORD attrib = GetFileAttrib(path);
if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
{
ClearBase();
Attrib = attrib;
Name = path + rootSize;
Name.DeleteFrom(2); // we don't need backslash (C:)
return true;
}
}
else if (IS_PATH_SEPAR(path[0]))
if (path[1] == 0)
{
DWORD attrib = GetFileAttrib(path);
if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
@ -535,21 +552,9 @@ bool CFileInfo::Find(CFSTR path)
return true;
}
}
else if (NName::IsDrivePath(path + rootSize) && path[rootSize + 3] == 0)
{
DWORD attrib = GetFileAttrib(path);
if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
{
ClearBase();
Attrib = attrib;
Name = path + rootSize;
Name.DeleteFrom(2); // we don't need backslash (C:)
return true;
}
}
else
{
unsigned prefixSize = GetNetworkServerPrefixSize(path);
const unsigned prefixSize = GetNetworkServerPrefixSize(path);
if (prefixSize > 0 && path[prefixSize] != 0)
{
if (NName::FindSepar(path + prefixSize) < 0)
@ -563,7 +568,7 @@ bool CFileInfo::Find(CFSTR path)
{
if (Name == FTEXT("."))
{
Name = path + prefixSize;;
Name = path + prefixSize;
return true;
}
isOK = true;
@ -583,17 +588,17 @@ bool CFileInfo::Find(CFSTR path)
return true;
}
}
::SetLastError(lastError);
// ::SetLastError(lastError);
}
}
}
}
}
#endif
return false;
return finder.FindFirst(path, *this);
}
bool DoesFileExist(CFSTR name)
{
CFileInfo fi;
@ -706,7 +711,7 @@ bool MyGetLogicalDriveStrings(CObjectVector<FString> &driveStrings)
driveStrings.Add(fas2fs(s));
}
}
return prev == newSize;;
return prev == newSize;
}
else
#endif

View File

@ -374,54 +374,66 @@ static bool ResolveDotsFolders(UString &s)
#ifdef _WIN32
// s.Replace(L'/', WCHAR_PATH_SEPARATOR);
#endif
for (unsigned i = 0;;)
{
wchar_t c = s[i];
const wchar_t c = s[i];
if (c == 0)
return true;
if (c == '.' && (i == 0 || IS_SEPAR(s[i - 1])))
{
wchar_t c1 = s[i + 1];
const wchar_t c1 = s[i + 1];
if (c1 == '.')
{
wchar_t c2 = s[i + 2];
const wchar_t c2 = s[i + 2];
if (IS_SEPAR(c2) || c2 == 0)
{
if (i == 0)
return false;
int k = i - 2;
for (; k >= 0; k--)
if (IS_SEPAR(s[(unsigned)k]))
i += 2;
for (;; k--)
{
if (k < 0)
return false;
if (!IS_SEPAR(s[(unsigned)k]))
break;
}
do
k--;
while (k >= 0 && !IS_SEPAR(s[(unsigned)k]));
unsigned num;
if (k >= 0)
{
num = i + 2 - k;
num = i - k;
i = k;
}
else
{
num = (c2 == 0 ? (i + 2) : (i + 3));
num = (c2 == 0 ? i : (i + 1));
i = 0;
}
s.Delete(i, num);
continue;
}
}
else
else if (IS_SEPAR(c1) || c1 == 0)
{
if (IS_SEPAR(c1) || c1 == 0)
{
unsigned num = 2;
if (i != 0)
i--;
else if (c1 == 0)
num = 1;
s.Delete(i, num);
continue;
}
unsigned num = 2;
if (i != 0)
i--;
else if (c1 == 0)
num = 1;
s.Delete(i, num);
continue;
}
}
i++;
}
}

View File

@ -1,8 +1,8 @@
7-Zip method IDs for 7z and xz archives
---------------------------------------
Version: 15.06
Date: 2015-06-23
Version: 16.03
Date: 2016-09-27
Each compression or crypto method in 7z is associated with unique binary value (ID).
The length of ID in bytes is arbitrary but it can not exceed 63 bits (8 bytes).
@ -122,7 +122,8 @@ List of defined IDs
F7 - External codecs (that are not included to 7-Zip)
0x xx - reserved
10 xx - reserved
10 xx - reserved (LZHAM)
11 xx - reserved (Zstd)
06.. - Crypto

View File

@ -1,9 +1,32 @@
HISTORY of the LZMA SDK
-----------------------
16.04 2016-10-04
-------------------------
- The bug was fixed in DllSecur.c.
16.03 2016-09-28
-------------------------
- SFX modules now use some protection against DLL preloading attack.
- Some bugs in 7z code were fixed.
16.02 2016-05-21
-------------------------
- The BUG in 16.00 - 16.01 was fixed:
Split Handler (SplitHandler.cpp) returned incorrect
total size value (kpidSize) for split archives.
16.01 2016-05-19
-------------------------
- Some internal changes to reduce the number of compiler warnings.
16.00 2016-05-10
-------------------------
- Some bugs were fixed,
- Some bugs were fixed.
15.12 2015-11-19

View File

@ -1,4 +1,4 @@
LZMA SDK 16.00
LZMA SDK 16.04
--------------
LZMA SDK provides the documentation, samples, header files,

View File

@ -413,6 +413,7 @@ end
MAME_DIR .. "3rdparty/lzma/C/BraIA64.c",
MAME_DIR .. "3rdparty/lzma/C/CpuArch.c",
MAME_DIR .. "3rdparty/lzma/C/Delta.c",
MAME_DIR .. "3rdparty/lzma/C/DllSecur.c",
MAME_DIR .. "3rdparty/lzma/C/LzFind.c",
-- MAME_DIR .. "3rdparty/lzma/C/LzFindMt.c",
MAME_DIR .. "3rdparty/lzma/C/Lzma2Dec.c",
@ -1583,4 +1584,4 @@ project "linenoise-ng"
MAME_DIR .. "3rdparty/linenoise-ng/src/linenoise.cpp",
MAME_DIR .. "3rdparty/linenoise-ng/src/wcwidth.cpp",
}
end
end