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

View File

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

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

@ -1,5 +1,5 @@
/* Aes.c -- AES encryption / decryption /* Aes.c -- AES encryption / decryption
2015-02-23 : Igor Pavlov : Public domain */ 2016-05-21 : Igor Pavlov : Public domain */
#include "Precomp.h" #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]; UInt32 r = w[i];
w[i] = w[i] =
D[ Sbox[gb0(r)]] ^ D[ (unsigned)Sbox[gb0(r)]] ^
D[0x100 + Sbox[gb1(r)]] ^ D[0x100 + (unsigned)Sbox[gb1(r)]] ^
D[0x200 + Sbox[gb2(r)]] ^ D[0x200 + (unsigned)Sbox[gb2(r)]] ^
D[0x300 + Sbox[gb3(r)]]; D[0x300 + (unsigned)Sbox[gb3(r)]];
} }
} }

View File

@ -1,5 +1,5 @@
/* CpuArch.h -- CPU specific code /* CpuArch.h -- CPU specific code
2015-12-01: Igor Pavlov : Public domain */ 2016-06-09: Igor Pavlov : Public domain */
#ifndef __CPU_ARCH_H #ifndef __CPU_ARCH_H
#define __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(__MIPSEL) \
|| defined(_MIPSEL) \ || defined(_MIPSEL) \
|| defined(__BFIN__) \
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
#define MY_CPU_LE #define MY_CPU_LE
#endif #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 /* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
2015-11-08 : Igor Pavlov : Public domain */ 2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
@ -9,9 +9,6 @@
#include "Bra.h" #include "Bra.h"
#include "LzmaDec.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) SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
{ {
unsigned i; 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) SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)
{ {
ISzAlloc g_Alloc = { SzAlloc, SzFree };
SRes res; SRes res;
int useFilter; int useFilter;
SizeT inSizePure; SizeT inSizePure;

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
/* Ppmd.h -- PPMD codec common code /* 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 */ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
#ifndef __PPMD_H #ifndef __PPMD_H
@ -77,8 +77,8 @@ typedef
CPpmd_Byte_Ref; CPpmd_Byte_Ref;
#define PPMD_SetAllBitsIn256Bytes(p) \ #define PPMD_SetAllBitsIn256Bytes(p) \
{ unsigned i; for (i = 0; i < 256 / sizeof(p[0]); i += 8) { \ { unsigned z; for (z = 0; z < 256 / sizeof(p[0]); z += 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; }} 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 EXTERN_C_END

View File

@ -1,5 +1,5 @@
/* Ppmd7.c -- PPMdH codec /* 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 */ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
#include "Precomp.h" #include "Precomp.h"
@ -639,10 +639,10 @@ CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *escFreq)
unsigned nonMasked = p->MinContext->NumStats - numMasked; unsigned nonMasked = p->MinContext->NumStats - numMasked;
if (p->MinContext->NumStats != 256) 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) + (nonMasked < (unsigned)SUFFIX(p->MinContext)->NumStats - p->MinContext->NumStats) +
2 * (p->MinContext->SummFreq < 11 * p->MinContext->NumStats) + 2 * (unsigned)(p->MinContext->SummFreq < 11 * p->MinContext->NumStats) +
4 * (numMasked > nonMasked) + 4 * (unsigned)(numMasked > nonMasked) +
p->HiBitsFlag; p->HiBitsFlag;
{ {
unsigned r = (see->Summ >> see->Shift); unsigned r = (see->Summ >> see->Shift);

View File

@ -1,5 +1,5 @@
/* Ppmd7.h -- PPMdH compression codec /* 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 is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
/* This code supports virtual RangeDecoder and includes the implementation /* This code supports virtual RangeDecoder and includes the implementation
@ -86,10 +86,10 @@ void Ppmd7_Update2(CPpmd7 *p);
void Ppmd7_UpdateBin(CPpmd7 *p); void Ppmd7_UpdateBin(CPpmd7 *p);
#define Ppmd7_GetBinSumm(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->NS2BSIndx[Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] + \
(p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]) + \ (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)] ((p->RunLength >> 26) & 0x20)]
CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale); CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale);

View File

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

View File

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

View File

@ -187,6 +187,14 @@ SOURCE=..\..\Delta.h
# End Source File # End Source File
# Begin 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 SOURCE=..\..\Lzma2Dec.c
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

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

View File

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

View File

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

View File

@ -148,9 +148,9 @@ HRESULT CEncoder::CreateMixerCoder(
RINOK(_mixer->SetBindInfo(_bindInfo)); 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; CCreatedCoder cod;
@ -410,9 +410,9 @@ HRESULT CEncoder::Encode(
mtOutStreamNotifySpec->_stream = outStream; mtOutStreamNotifySpec->_stream = outStream;
mtOutStreamNotifySpec->_mtProgresSpec = mtProgressSpec; 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; continue;
} }
int i = _bindInfo.FindStream_in_PackStreams(outIndex); int si = _bindInfo.FindStream_in_PackStreams(outIndex);
if (i >= 0) if (si >= 0)
_bindInfo.PackStreams.MoveToFront(i); _bindInfo.PackStreams.MoveToFront(si);
break; break;
} }
} }

View File

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

View File

@ -429,11 +429,11 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
name = "LZMA2"; name = "LZMA2";
if (propsSize == 1) if (propsSize == 1)
{ {
Byte p = props[0]; Byte d = props[0];
if ((p & 1) == 0) if ((d & 1) == 0)
ConvertUInt32ToString((UInt32)((p >> 1) + 12), s); ConvertUInt32ToString((UInt32)((d >> 1) + 12), s);
else else
GetStringForSizeValue(s, 3 << ((p >> 1) + 11)); GetStringForSizeValue(s, 3 << ((d >> 1) + 11));
} }
} }
else if (id == k_PPMD) 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) static HRESULT ParseBond(UString &srcString, UInt32 &coder, UInt32 &stream)
{ {
stream = 0; stream = 0;
int index = ParseStringToUInt32(srcString, coder); {
unsigned index = ParseStringToUInt32(srcString, coder);
if (index == 0) if (index == 0)
return E_INVALIDARG; return E_INVALIDARG;
srcString.DeleteFrontal(index); srcString.DeleteFrontal(index);
}
if (srcString[0] == 's') if (srcString[0] == 's')
{ {
srcString.Delete(0); srcString.Delete(0);
int index = ParseStringToUInt32(srcString, stream); unsigned index = ParseStringToUInt32(srcString, stream);
if (index == 0) if (index == 0)
return E_INVALIDARG; return E_INVALIDARG;
srcString.DeleteFrontal(index); srcString.DeleteFrontal(index);

View File

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

View File

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

View File

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

View File

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

View File

@ -203,7 +203,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
_streams.Add(stream); _streams.Add(stream);
{ {
UInt64 numFiles = _streams.Size(); const UInt64 numFiles = _streams.Size();
RINOK(callback->SetCompleted(&numFiles, NULL)); RINOK(callback->SetCompleted(&numFiles, NULL));
} }
@ -218,7 +218,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
break; break;
if (result != S_OK) if (result != S_OK)
return result; return result;
if (!stream) if (!nextStream)
break; break;
{ {
/* /*
@ -228,14 +228,14 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
return E_INVALIDARG; return E_INVALIDARG;
size = prop.uhVal.QuadPart; size = prop.uhVal.QuadPart;
*/ */
RINOK(stream->Seek(0, STREAM_SEEK_END, &size)); RINOK(nextStream->Seek(0, STREAM_SEEK_END, &size));
RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL)); RINOK(nextStream->Seek(0, STREAM_SEEK_SET, NULL));
} }
_totalSize += size; _totalSize += size;
_sizes.Add(size); _sizes.Add(size);
_streams.Add(nextStream); _streams.Add(nextStream);
{ {
UInt64 numFiles = _streams.Size(); const UInt64 numFiles = _streams.Size();
RINOK(callback->SetCompleted(&numFiles, NULL)); 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 (outStreamSpec)
{ {
if (!stdOutMode)
Print_Size("Output size: ", outStreamSpec->ProcessedSize);
if (outStreamSpec->Close() != S_OK) if (outStreamSpec->Close() != S_OK)
throw "File closing error"; throw "File closing error";
} }

View File

@ -804,6 +804,15 @@ SOURCE=..\..\..\..\C\Delta.h
# End Source File # End Source File
# Begin 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 SOURCE=..\..\..\..\C\Lzma2Dec.c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
# End Source File # End Source File

View File

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

View File

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

View File

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

View File

@ -706,6 +706,15 @@ SOURCE=..\..\..\..\C\Delta.h
# End Source File # End Source File
# Begin 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 SOURCE=..\..\..\..\C\Lzma2Dec.c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
# End Source File # End Source File

View File

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

View File

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

View File

@ -888,6 +888,15 @@ SOURCE=..\..\..\..\C\Delta.h
# End Source File # End Source File
# Begin 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 SOURCE=..\..\..\..\C\Lzma2Dec.c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
# End Source File # End Source File

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -387,7 +387,7 @@ static void AddRenamePair(CObjectVector<CRenamePair> *renamePairs,
val.Add_LF(); val.Add_LF();
if (type == NRecursedType::kRecursed) if (type == NRecursedType::kRecursed)
val.AddAscii("-r"); val.AddAscii("-r");
else if (type == NRecursedType::kRecursed) else if (type == NRecursedType::kWildcardOnlyRecursed)
val.AddAscii("-r0"); val.AddAscii("-r0");
throw CArcCmdLineException("Unsupported rename command:", val); 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) if (_item.IsAltStream && _item.ParentIndex != (UInt32)(Int32)-1)
{ {
CIndexToPathPair pair(_item.ParentIndex); int renIndex = _renamedFiles.FindInSorted(CIndexToPathPair(_item.ParentIndex));
int renIndex = _renamedFiles.FindInSorted(pair);
if (renIndex >= 0) if (renIndex >= 0)
{ {
const CIndexToPathPair &pair = _renamedFiles[renIndex]; const CIndexToPathPair &pair = _renamedFiles[renIndex];
@ -1319,7 +1318,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
if (needWriteFile) if (needWriteFile)
{ {
_outFileStreamSpec = new COutFileStream; _outFileStreamSpec = new COutFileStream;
CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec); CMyComPtr<ISequentialOutStream> outStreamLoc2(_outFileStreamSpec);
if (!_outFileStreamSpec->Open(fullProcessedPath, _isSplit ? OPEN_ALWAYS: CREATE_ALWAYS)) if (!_outFileStreamSpec->Open(fullProcessedPath, _isSplit ? OPEN_ALWAYS: CREATE_ALWAYS))
{ {
// if (::GetLastError() != ERROR_FILE_EXISTS || !isSplit) // 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)); RINOK(_outFileStreamSpec->Seek(_position, STREAM_SEEK_SET, NULL));
} }
_outFileStream = outStreamLoc; _outFileStream = outStreamLoc2;
} }
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -401,6 +401,14 @@ struct CArchiveLink
HRESULT Open2(COpenOptions &options, IOpenCallbackUI *callbackUI); HRESULT Open2(COpenOptions &options, IOpenCallbackUI *callbackUI);
HRESULT Open3(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); HRESULT ReOpen(COpenOptions &options);
}; };

View File

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

View File

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

View File

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

View File

@ -900,10 +900,10 @@ HRESULT Print_OpenArchive_Props(CStdOutStream &so, const CCodecs *codecs, const
RINOK(PrintArcProp(so, archive, kpidPhySize, NULL)); RINOK(PrintArcProp(so, archive, kpidPhySize, NULL));
if (er.TailSize != 0) if (er.TailSize != 0)
PrintPropNameAndNumber(so, kpidTailSize, er.TailSize); PrintPropNameAndNumber(so, kpidTailSize, er.TailSize);
{
UInt32 numProps; UInt32 numProps;
RINOK(archive->GetNumberOfArchiveProperties(&numProps)); RINOK(archive->GetNumberOfArchiveProperties(&numProps));
{
for (UInt32 j = 0; j < numProps; j++) for (UInt32 j = 0; j < numProps; j++)
{ {
CMyComBSTR name; CMyComBSTR name;
@ -1068,7 +1068,7 @@ HRESULT ListArchives(CCodecs *codecs,
g_StdOut << endl << kListing << arcPath << endl << endl; g_StdOut << endl << kListing << arcPath << endl << endl;
} }
HRESULT result = arcLink.Open3(options, &openCallback); HRESULT result = arcLink.Open_Strict(options, &openCallback);
if (result != S_OK) if (result != S_OK)
{ {
@ -1095,9 +1095,6 @@ HRESULT ListArchives(CCodecs *codecs,
} }
{ {
if (arcLink.NonOpen_ErrorInfo.ErrorFormatIndex >= 0)
numErrors++;
FOR_VECTOR (r, arcLink.Arcs) FOR_VECTOR (r, arcLink.Arcs)
{ {
const CArcErrorInfo &arc = arcLink.Arcs[r].ErrorInfo; 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; CWaitCursor waitCursor;
HANDLE h[] = { thread, _createDialogEvent }; HANDLE h[] = { thread, _createDialogEvent };
WRes res = WaitForMultipleObjects(ARRAY_SIZE(h), h, FALSE, kCreateDelay); WRes res2 = WaitForMultipleObjects(ARRAY_SIZE(h), h, FALSE, kCreateDelay);
if (res == WAIT_OBJECT_0 && !Sync.ThereIsMessage()) if (res2 == WAIT_OBJECT_0 && !Sync.ThereIsMessage())
return 0; return 0;
} }
_title = title; _title = title;

View File

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

View File

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

View File

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

View File

@ -130,7 +130,10 @@ WinXP-64 FindFirstFile():
\\Server\ - ERROR_INVALID_NAME \\Server\ - ERROR_INVALID_NAME
\\Server\Share - ERROR_BAD_NETPATH \\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 \\Server\Share\ - ERROR_FILE_NOT_FOUND
\\?\UNC\Server\Share - ERROR_INVALID_NAME \\?\UNC\Server\Share - ERROR_INVALID_NAME
@ -508,11 +511,10 @@ bool CFileInfo::Find(CFSTR path)
#endif #endif
CFindFile finder; CFindFile finder;
if (finder.FindFirst(path, *this))
return true;
#if defined(_WIN32) && !defined(UNDER_CE) #if defined(_WIN32) && !defined(UNDER_CE)
{ {
/*
DWORD lastError = GetLastError(); DWORD lastError = GetLastError();
if (lastError == ERROR_FILE_NOT_FOUND if (lastError == ERROR_FILE_NOT_FOUND
|| lastError == ERROR_BAD_NETPATH // XP64: "\\Server\Share" || lastError == ERROR_BAD_NETPATH // XP64: "\\Server\Share"
@ -520,22 +522,13 @@ bool CFileInfo::Find(CFSTR path)
|| lastError == ERROR_INVALID_NAME // XP64: "\\?\UNC\Server\Share" || lastError == ERROR_INVALID_NAME // XP64: "\\?\UNC\Server\Share"
|| lastError == ERROR_BAD_PATHNAME // Win7: "\\?\UNC\Server\Share" || lastError == ERROR_BAD_PATHNAME // Win7: "\\?\UNC\Server\Share"
) )
{ */
unsigned rootSize = 0; unsigned rootSize = 0;
if (IsSuperPath(path)) if (IsSuperPath(path))
rootSize = kSuperPathPrefixSize; rootSize = kSuperPathPrefixSize;
if (IS_PATH_SEPAR(path[0]) && path[1] == 0)
{ if (NName::IsDrivePath(path + rootSize) && path[rootSize + 3] == 0)
DWORD attrib = GetFileAttrib(path);
if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
{
ClearBase();
Name.Empty();
Attrib = attrib;
return true;
}
}
else if (NName::IsDrivePath(path + rootSize) && path[rootSize + 3] == 0)
{ {
DWORD attrib = GetFileAttrib(path); DWORD attrib = GetFileAttrib(path);
if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0) if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
@ -547,9 +540,21 @@ bool CFileInfo::Find(CFSTR path)
return true; 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)
{
ClearBase();
Name.Empty();
Attrib = attrib;
return true;
}
}
else else
{ {
unsigned prefixSize = GetNetworkServerPrefixSize(path); const unsigned prefixSize = GetNetworkServerPrefixSize(path);
if (prefixSize > 0 && path[prefixSize] != 0) if (prefixSize > 0 && path[prefixSize] != 0)
{ {
if (NName::FindSepar(path + prefixSize) < 0) if (NName::FindSepar(path + prefixSize) < 0)
@ -563,7 +568,7 @@ bool CFileInfo::Find(CFSTR path)
{ {
if (Name == FTEXT(".")) if (Name == FTEXT("."))
{ {
Name = path + prefixSize;; Name = path + prefixSize;
return true; return true;
} }
isOK = true; isOK = true;
@ -583,17 +588,17 @@ bool CFileInfo::Find(CFSTR path)
return true; return true;
} }
} }
::SetLastError(lastError); // ::SetLastError(lastError);
}
} }
} }
} }
} }
#endif #endif
return false; return finder.FindFirst(path, *this);
} }
bool DoesFileExist(CFSTR name) bool DoesFileExist(CFSTR name)
{ {
CFileInfo fi; CFileInfo fi;
@ -706,7 +711,7 @@ bool MyGetLogicalDriveStrings(CObjectVector<FString> &driveStrings)
driveStrings.Add(fas2fs(s)); driveStrings.Add(fas2fs(s));
} }
} }
return prev == newSize;; return prev == newSize;
} }
else else
#endif #endif

View File

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

View File

@ -1,8 +1,8 @@
7-Zip method IDs for 7z and xz archives 7-Zip method IDs for 7z and xz archives
--------------------------------------- ---------------------------------------
Version: 15.06 Version: 16.03
Date: 2015-06-23 Date: 2016-09-27
Each compression or crypto method in 7z is associated with unique binary value (ID). 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). 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) F7 - External codecs (that are not included to 7-Zip)
0x xx - reserved 0x xx - reserved
10 xx - reserved 10 xx - reserved (LZHAM)
11 xx - reserved (Zstd)
06.. - Crypto 06.. - Crypto

View File

@ -1,9 +1,32 @@
HISTORY of the LZMA SDK 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 16.00 2016-05-10
------------------------- -------------------------
- Some bugs were fixed, - Some bugs were fixed.
15.12 2015-11-19 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, 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/BraIA64.c",
MAME_DIR .. "3rdparty/lzma/C/CpuArch.c", MAME_DIR .. "3rdparty/lzma/C/CpuArch.c",
MAME_DIR .. "3rdparty/lzma/C/Delta.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/LzFind.c",
-- MAME_DIR .. "3rdparty/lzma/C/LzFindMt.c", -- MAME_DIR .. "3rdparty/lzma/C/LzFindMt.c",
MAME_DIR .. "3rdparty/lzma/C/Lzma2Dec.c", MAME_DIR .. "3rdparty/lzma/C/Lzma2Dec.c",