Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2008-12-31 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:58 +0300
commit3a524e5ba2d7bb0c46e11502822f8093dd2ab0f4 (patch)
treeb33da9cac0a5fc22a16bdf4de106c8a9eefd1465 /CPP/7zip/Archive
parentc1f1243a70558e86e14b1ea09dc287737378894b (diff)
4.634.63
Diffstat (limited to 'CPP/7zip/Archive')
-rwxr-xr-xCPP/7zip/Archive/7z/7zDecode.cpp19
-rwxr-xr-xCPP/7zip/Archive/7z/7zEncode.cpp6
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandler.cpp53
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandlerOut.cpp48
-rwxr-xr-xCPP/7zip/Archive/7z/7zIn.cpp171
-rwxr-xr-xCPP/7zip/Archive/7z/7zIn.h14
-rwxr-xr-xCPP/7zip/Archive/7z/7zItem.h6
-rwxr-xr-xCPP/7zip/Archive/7z/7zOut.cpp10
-rwxr-xr-xCPP/7zip/Archive/7z/7zUpdate.cpp53
-rwxr-xr-xCPP/7zip/Archive/ArjHandler.cpp10
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2Handler.cpp6
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp2
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHandler.cpp20
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmHandler.cpp13
-rwxr-xr-xCPP/7zip/Archive/Common/HandlerOut.cpp76
-rwxr-xr-xCPP/7zip/Archive/Common/HandlerOut.h4
-rwxr-xr-xCPP/7zip/Archive/Common/OutStreamWithCRC.h4
-rwxr-xr-xCPP/7zip/Archive/Common/OutStreamWithSha1.h6
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHandler.cpp18
-rwxr-xr-xCPP/7zip/Archive/DebHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/DmgHandler.cpp6
-rwxr-xr-xCPP/7zip/Archive/ElfHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHandlerOut.cpp13
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipUpdate.cpp10
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoHandler.cpp16
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhHandler.cpp11
-rwxr-xr-xCPP/7zip/Archive/MachoHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/MubHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/PeHandler.cpp8
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHandler.cpp22
-rwxr-xr-xCPP/7zip/Archive/Rar/RarIn.h8
-rwxr-xr-xCPP/7zip/Archive/RpmHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/Split/SplitHandler.cpp16
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHandler.cpp20
-rwxr-xr-xCPP/7zip/Archive/Tar/TarUpdate.cpp9
-rwxr-xr-xCPP/7zip/Archive/Udf/UdfHandler.cpp14
-rwxr-xr-xCPP/7zip/Archive/Wim/WimIn.cpp2
-rwxr-xr-xCPP/7zip/Archive/Wim/WimIn.h8
-rwxr-xr-xCPP/7zip/Archive/XarHandler.cpp6
-rwxr-xr-xCPP/7zip/Archive/ZHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipAddCommon.cpp17
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipAddCommon.h16
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.cpp146
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandlerOut.cpp19
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipUpdate.cpp21
45 files changed, 512 insertions, 427 deletions
diff --git a/CPP/7zip/Archive/7z/7zDecode.cpp b/CPP/7zip/Archive/7z/7zDecode.cpp
index e630538d..2d25ff2e 100755
--- a/CPP/7zip/Archive/7z/7zDecode.cpp
+++ b/CPP/7zip/Archive/7z/7zDecode.cpp
@@ -2,15 +2,12 @@
#include "StdAfx.h"
-#include "7zDecode.h"
-
-#include "../../IPassword.h"
+#include "../../Common/LimitedStreams.h"
#include "../../Common/LockedStream.h"
-#include "../../Common/StreamObjects.h"
#include "../../Common/ProgressUtils.h"
-#include "../../Common/LimitedStreams.h"
-#include "../../Common/CreateCoder.h"
-#include "../../Common/FilterCoder.h"
+#include "../../Common/StreamObjects.h"
+
+#include "7zDecode.h"
namespace NArchive {
namespace N7z {
@@ -105,6 +102,8 @@ HRESULT CDecoder::Decode(
#endif
)
{
+ if (!folderInfo.CheckStructure())
+ return E_NOTIMPL;
#ifndef _NO_CRYPTO
passwordIsDefined = false;
#endif
@@ -229,13 +228,13 @@ HRESULT CDecoder::Decode(
decoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
if (setDecoderProperties)
{
- const CByteBuffer &properties = coderInfo.Properties;
- size_t size = properties.GetCapacity();
+ const CByteBuffer &props = coderInfo.Props;
+ size_t size = props.GetCapacity();
if (size > 0xFFFFFFFF)
return E_NOTIMPL;
if (size > 0)
{
- RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)properties, (UInt32)size));
+ RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)props, (UInt32)size));
}
}
}
diff --git a/CPP/7zip/Archive/7z/7zEncode.cpp b/CPP/7zip/Archive/7z/7zEncode.cpp
index b5a43f56..01803842 100755
--- a/CPP/7zip/Archive/7z/7zEncode.cpp
+++ b/CPP/7zip/Archive/7z/7zEncode.cpp
@@ -233,8 +233,8 @@ HRESULT CEncoder::Encode(
outStreamSpec->Init();
writeCoderProperties->WriteCoderProperties(outStream);
size_t size = outStreamSpec->GetSize();
- encodingInfo.Properties.SetCapacity(size);
- memmove(encodingInfo.Properties, outStreamSpec->GetBuffer(), size);
+ encodingInfo.Props.SetCapacity(size);
+ memmove(encodingInfo.Props, outStreamSpec->GetBuffer(), size);
}
}
@@ -278,7 +278,7 @@ HRESULT CEncoder::Encode(
folderItem.UnpackSizes.Add(streamSize);
}
for (i = numMethods - 1; i >= 0; i--)
- folderItem.Coders[numMethods - 1 - i].Properties = _codersInfo[i].Properties;
+ folderItem.Coders[numMethods - 1 - i].Props = _codersInfo[i].Props;
return S_OK;
}
diff --git a/CPP/7zip/Archive/7z/7zHandler.cpp b/CPP/7zip/Archive/7z/7zHandler.cpp
index 76b3c72d..44131fae 100755
--- a/CPP/7zip/Archive/7z/7zHandler.cpp
+++ b/CPP/7zip/Archive/7z/7zHandler.cpp
@@ -2,25 +2,29 @@
#include "StdAfx.h"
-#include "7zHandler.h"
-#include "7zProperties.h"
+extern "C"
+{
+ #include "../../../../C/CpuArch.h"
+}
-#include "../../../Common/IntToString.h"
#include "../../../Common/ComTry.h"
-#include "../../../Windows/Defs.h"
+#include "../../../Common/IntToString.h"
+
+#ifdef COMPRESS_MT
+#include "../../../Windows/System.h"
+#endif
#include "../Common/ItemNameUtils.h"
+#include "7zHandler.h"
+#include "7zProperties.h"
+
#ifdef __7Z_SET_PROPERTIES
#ifdef EXTRACT_ONLY
#include "../Common/ParseProperties.h"
#endif
#endif
-#ifdef COMPRESS_MT
-#include "../../../Windows/System.h"
-#endif
-
using namespace NWindows;
extern UString ConvertMethodIdToString(UInt64 id);
@@ -191,13 +195,6 @@ static inline UString GetHex2(Byte value)
static const UInt64 k_AES = 0x06F10701;
-#ifndef _SFX
-static inline UInt32 GetUInt32FromMemLE(const Byte *p)
-{
- return p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24);
-}
-#endif
-
bool CHandler::IsEncrypted(UInt32 index2) const
{
CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
@@ -291,33 +288,31 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
methodsString += methodName;
if (coderInfo.MethodID == k_LZMA)
{
- if (coderInfo.Properties.GetCapacity() >= 5)
+ if (coderInfo.Props.GetCapacity() >= 5)
{
methodsString += L":";
- UInt32 dicSize = GetUInt32FromMemLE(
- ((const Byte *)coderInfo.Properties + 1));
+ UInt32 dicSize = GetUi32((const Byte *)coderInfo.Props + 1);
methodsString += GetStringForSizeValue(dicSize);
}
}
else if (coderInfo.MethodID == k_PPMD)
{
- if (coderInfo.Properties.GetCapacity() >= 5)
+ if (coderInfo.Props.GetCapacity() >= 5)
{
- Byte order = *(const Byte *)coderInfo.Properties;
+ Byte order = *(const Byte *)coderInfo.Props;
methodsString += L":o";
methodsString += ConvertUInt32ToString(order);
methodsString += L":mem";
- UInt32 dicSize = GetUInt32FromMemLE(
- ((const Byte *)coderInfo.Properties + 1));
+ UInt32 dicSize = GetUi32((const Byte *)coderInfo.Props + 1);
methodsString += GetStringForSizeValue(dicSize);
}
}
else if (coderInfo.MethodID == k_AES)
{
- if (coderInfo.Properties.GetCapacity() >= 1)
+ if (coderInfo.Props.GetCapacity() >= 1)
{
methodsString += L":";
- const Byte *data = (const Byte *)coderInfo.Properties;
+ const Byte *data = (const Byte *)coderInfo.Props;
Byte firstByte = *data++;
UInt32 numCyclesPower = firstByte & 0x3F;
methodsString += ConvertUInt32ToString(numCyclesPower);
@@ -328,7 +323,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
return S_OK;
UInt32 saltSize = (firstByte >> 7) & 1;
UInt32 ivSize = (firstByte >> 6) & 1;
- if (coderInfo.Properties.GetCapacity() >= 2)
+ if (coderInfo.Props.GetCapacity() >= 2)
{
Byte secondByte = *data++;
saltSize += (secondByte >> 4);
@@ -340,18 +335,18 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
}
else
{
- if (coderInfo.Properties.GetCapacity() > 0)
+ if (coderInfo.Props.GetCapacity() > 0)
{
methodsString += L":[";
- for (size_t bi = 0; bi < coderInfo.Properties.GetCapacity(); bi++)
+ for (size_t bi = 0; bi < coderInfo.Props.GetCapacity(); bi++)
{
- if (bi > 5 && bi + 1 < coderInfo.Properties.GetCapacity())
+ if (bi > 5 && bi + 1 < coderInfo.Props.GetCapacity())
{
methodsString += L"..";
break;
}
else
- methodsString += GetHex2(coderInfo.Properties[bi]);
+ methodsString += GetHex2(coderInfo.Props[bi]);
}
methodsString += L"]";
}
diff --git a/CPP/7zip/Archive/7z/7zHandlerOut.cpp b/CPP/7zip/Archive/7z/7zHandlerOut.cpp
index ac9ef987..3e2591d5 100755
--- a/CPP/7zip/Archive/7z/7zHandlerOut.cpp
+++ b/CPP/7zip/Archive/7z/7zHandlerOut.cpp
@@ -2,20 +2,20 @@
#include "StdAfx.h"
-#include "7zHandler.h"
-#include "7zOut.h"
-#include "7zUpdate.h"
-
#include "../../../Windows/PropVariant.h"
#include "../../../Common/ComTry.h"
#include "../../../Common/StringToInt.h"
-#include "../../IPassword.h"
+
#include "../../ICoder.h"
#include "../Common/ItemNameUtils.h"
#include "../Common/ParseProperties.h"
+#include "7zHandler.h"
+#include "7zOut.h"
+#include "7zUpdate.h"
+
using namespace NWindows;
namespace NArchive {
@@ -85,28 +85,28 @@ HRESULT CHandler::SetCompressionMethod(
COneMethodInfo oneMethodInfo;
oneMethodInfo.MethodName = kLZMAMethodName;
{
- CProp property;
- property.Id = NCoderPropID::kMatchFinder;
- property.Value = kLzmaMatchFinderForHeaders;
- oneMethodInfo.Properties.Add(property);
+ CProp prop;
+ prop.Id = NCoderPropID::kMatchFinder;
+ prop.Value = kLzmaMatchFinderForHeaders;
+ oneMethodInfo.Props.Add(prop);
}
{
- CProp property;
- property.Id = NCoderPropID::kAlgorithm;
- property.Value = kAlgorithmForHeaders;
- oneMethodInfo.Properties.Add(property);
+ CProp prop;
+ prop.Id = NCoderPropID::kAlgorithm;
+ prop.Value = kAlgorithmForHeaders;
+ oneMethodInfo.Props.Add(prop);
}
{
- CProp property;
- property.Id = NCoderPropID::kNumFastBytes;
- property.Value = UInt32(kNumFastBytesForHeaders);
- oneMethodInfo.Properties.Add(property);
+ CProp prop;
+ prop.Id = NCoderPropID::kNumFastBytes;
+ prop.Value = (UInt32)kNumFastBytesForHeaders;
+ oneMethodInfo.Props.Add(prop);
}
{
- CProp property;
- property.Id = NCoderPropID::kDictionarySize;
- property.Value = UInt32(kDictionaryForHeaders);
- oneMethodInfo.Properties.Add(property);
+ CProp prop;
+ prop.Id = NCoderPropID::kDictionarySize;
+ prop.Value = (UInt32)kDictionaryForHeaders;
+ oneMethodInfo.Props.Add(prop);
}
headerMethodInfoVector.Add(oneMethodInfo);
HRESULT res = SetCompressionMethod(headerMethod, headerMethodInfoVector
@@ -155,14 +155,14 @@ HRESULT CHandler::SetCompressionMethod(
EXTERNAL_CODECS_VARS
oneMethodInfo.MethodName, methodFull.Id, methodFull.NumInStreams, methodFull.NumOutStreams))
return E_INVALIDARG;
- methodFull.Properties = oneMethodInfo.Properties;
+ methodFull.Props = oneMethodInfo.Props;
methodMode.Methods.Add(methodFull);
if (!_numSolidBytesDefined)
{
- for (int j = 0; j < methodFull.Properties.Size(); j++)
+ for (int j = 0; j < methodFull.Props.Size(); j++)
{
- const CProp &prop = methodFull.Properties[j];
+ const CProp &prop = methodFull.Props[j];
if ((prop.Id == NCoderPropID::kDictionarySize ||
prop.Id == NCoderPropID::kUsedMemorySize) && prop.Value.vt == VT_UI4)
{
diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp
index 6cf3fdf6..ab78eeae 100755
--- a/CPP/7zip/Archive/7z/7zIn.cpp
+++ b/CPP/7zip/Archive/7z/7zIn.cpp
@@ -2,16 +2,18 @@
#include "StdAfx.h"
-#include "7zIn.h"
-#include "7zDecode.h"
-#include "../../Common/StreamObjects.h"
-#include "../../Common/StreamUtils.h"
extern "C"
{
#include "../../../../C/7zCrc.h"
#include "../../../../C/CpuArch.h"
}
+#include "../../Common/StreamObjects.h"
+#include "../../Common/StreamUtils.h"
+
+#include "7zDecode.h"
+#include "7zIn.h"
+
#define Get16(p) GetUi16(p)
#define Get32(p) GetUi32(p)
#define Get64(p) GetUi64(p)
@@ -24,6 +26,86 @@ extern "C"
namespace NArchive {
namespace N7z {
+static void BoolVector_Fill_False(CBoolVector &v, int size)
+{
+ v.Clear();
+ v.Reserve(size);
+ for (int i = 0; i < size; i++)
+ v.Add(false);
+}
+
+static bool BoolVector_GetAndSet(CBoolVector &v, UInt32 index)
+{
+ if (index >= (UInt32)v.Size())
+ return true;
+ bool res = v[index];
+ v[index] = true;
+ return res;
+}
+
+bool CFolder::CheckStructure() const
+{
+ const int kNumCodersMax = sizeof(UInt32) * 8; // don't change it
+ const int kMaskSize = sizeof(UInt32) * 8; // it must be >= kNumCodersMax
+ const int kNumBindsMax = 32;
+
+ if (Coders.Size() > kNumCodersMax || BindPairs.Size() > kNumBindsMax)
+ return false;
+
+ {
+ CBoolVector v;
+ BoolVector_Fill_False(v, BindPairs.Size() + PackStreams.Size());
+
+ int i;
+ for (i = 0; i < BindPairs.Size(); i++)
+ if (BoolVector_GetAndSet(v, BindPairs[i].InIndex))
+ return false;
+ for (i = 0; i < PackStreams.Size(); i++)
+ if (BoolVector_GetAndSet(v, PackStreams[i]))
+ return false;
+
+ BoolVector_Fill_False(v, UnpackSizes.Size());
+ for (i = 0; i < BindPairs.Size(); i++)
+ if (BoolVector_GetAndSet(v, BindPairs[i].OutIndex))
+ return false;
+ }
+
+ UInt32 mask[kMaskSize];
+ int i;
+ for (i = 0; i < kMaskSize; i++)
+ mask[i] = 0;
+
+ {
+ CIntVector inStreamToCoder, outStreamToCoder;
+ for (i = 0; i < Coders.Size(); i++)
+ {
+ CNum j;
+ const CCoderInfo &coder = Coders[i];
+ for (j = 0; j < coder.NumInStreams; j++)
+ inStreamToCoder.Add(i);
+ for (j = 0; j < coder.NumOutStreams; j++)
+ outStreamToCoder.Add(i);
+ }
+
+ for (i = 0; i < BindPairs.Size(); i++)
+ {
+ const CBindPair &bp = BindPairs[i];
+ mask[inStreamToCoder[bp.InIndex]] |= (1 << outStreamToCoder[bp.OutIndex]);
+ }
+ }
+
+ for (i = 0; i < kMaskSize; i++)
+ for (int j = 0; j < kMaskSize; j++)
+ if (((1 << j) & mask[i]) != 0)
+ mask[i] |= mask[j];
+
+ for (i = 0; i < kMaskSize; i++)
+ if (((1 << i) & mask[i]) != 0)
+ return false;
+
+ return true;
+}
+
class CInArchiveException {};
static void ThrowException() { throw CInArchiveException(); }
@@ -323,9 +405,9 @@ void CInArchive::GetNextFolderItem(CFolder &folder)
}
if ((mainByte & 0x20) != 0)
{
- CNum propertiesSize = ReadNum();
- coder.Properties.SetCapacity((size_t)propertiesSize);
- ReadBytes((Byte *)coder.Properties, (size_t)propertiesSize);
+ CNum propsSize = ReadNum();
+ coder.Props.SetCapacity((size_t)propsSize);
+ ReadBytes((Byte *)coder.Props, (size_t)propsSize);
}
if ((mainByte & 0x80) != 0)
ThrowUnsupported();
@@ -334,31 +416,34 @@ void CInArchive::GetNextFolderItem(CFolder &folder)
numOutStreams += coder.NumOutStreams;
}
- CNum numBindPairs;
- numBindPairs = numOutStreams - 1;
+ CNum numBindPairs = numOutStreams - 1;
folder.BindPairs.Clear();
folder.BindPairs.Reserve(numBindPairs);
for (i = 0; i < numBindPairs; i++)
{
- CBindPair bindPair;
- bindPair.InIndex = ReadNum();
- bindPair.OutIndex = ReadNum();
- folder.BindPairs.Add(bindPair);
+ CBindPair bp;
+ bp.InIndex = ReadNum();
+ bp.OutIndex = ReadNum();
+ folder.BindPairs.Add(bp);
}
- CNum numPackedStreams = numInStreams - numBindPairs;
- folder.PackStreams.Reserve(numPackedStreams);
- if (numPackedStreams == 1)
+ if (numInStreams < numBindPairs)
+ ThrowUnsupported();
+ CNum numPackStreams = numInStreams - numBindPairs;
+ folder.PackStreams.Reserve(numPackStreams);
+ if (numPackStreams == 1)
{
- for (CNum j = 0; j < numInStreams; j++)
- if (folder.FindBindPairForInStream(j) < 0)
+ for (i = 0; i < numInStreams; i++)
+ if (folder.FindBindPairForInStream(i) < 0)
{
- folder.PackStreams.Add(j);
+ folder.PackStreams.Add(i);
break;
}
+ if (folder.PackStreams.Size() != 1)
+ ThrowUnsupported();
}
else
- for (i = 0; i < numPackedStreams; i++)
+ for (i = 0; i < numPackStreams; i++)
folder.PackStreams.Add(ReadNum());
}
@@ -376,7 +461,7 @@ void CInArchive::WaitAttribute(UInt64 attribute)
}
void CInArchive::ReadHashDigests(int numItems,
- CRecordVector<bool> &digestsDefined,
+ CBoolVector &digestsDefined,
CRecordVector<UInt32> &digests)
{
ReadBoolVector2(numItems, digestsDefined);
@@ -394,7 +479,7 @@ void CInArchive::ReadHashDigests(int numItems,
void CInArchive::ReadPackInfo(
UInt64 &dataOffset,
CRecordVector<UInt64> &packSizes,
- CRecordVector<bool> &packCRCsDefined,
+ CBoolVector &packCRCsDefined,
CRecordVector<UInt32> &packCRCs)
{
dataOffset = ReadNumber();
@@ -421,15 +506,11 @@ void CInArchive::ReadPackInfo(
}
if (packCRCsDefined.IsEmpty())
{
- packCRCsDefined.Reserve(numPackStreams);
- packCRCsDefined.Clear();
+ BoolVector_Fill_False(packCRCsDefined, numPackStreams);
packCRCs.Reserve(numPackStreams);
packCRCs.Clear();
for (CNum i = 0; i < numPackStreams; i++)
- {
- packCRCsDefined.Add(false);
packCRCs.Add(0);
- }
}
}
@@ -471,7 +552,7 @@ void CInArchive::ReadUnpackInfo(
return;
if (type == NID::kCRC)
{
- CRecordVector<bool> crcsDefined;
+ CBoolVector crcsDefined;
CRecordVector<UInt32> crcs;
ReadHashDigests(numFolders, crcsDefined, crcs);
for (i = 0; i < numFolders; i++)
@@ -490,7 +571,7 @@ void CInArchive::ReadSubStreamsInfo(
const CObjectVector<CFolder> &folders,
CRecordVector<CNum> &numUnpackStreamsInFolders,
CRecordVector<UInt64> &unpackSizes,
- CRecordVector<bool> &digestsDefined,
+ CBoolVector &digestsDefined,
CRecordVector<UInt32> &digests)
{
numUnpackStreamsInFolders.Clear();
@@ -551,7 +632,7 @@ void CInArchive::ReadSubStreamsInfo(
{
if (type == NID::kCRC)
{
- CRecordVector<bool> digestsDefined2;
+ CBoolVector digestsDefined2;
CRecordVector<UInt32> digests2;
ReadHashDigests(numDigests, digestsDefined2, digests2);
int digestIndex = 0;
@@ -576,13 +657,10 @@ void CInArchive::ReadSubStreamsInfo(
{
if (digestsDefined.IsEmpty())
{
- digestsDefined.Clear();
+ BoolVector_Fill_False(digestsDefined, numDigestsTotal);
digests.Clear();
for (int i = 0; i < numDigestsTotal; i++)
- {
- digestsDefined.Add(false);
digests.Add(0);
- }
}
return;
}
@@ -596,12 +674,12 @@ void CInArchive::ReadStreamsInfo(
const CObjectVector<CByteBuffer> *dataVector,
UInt64 &dataOffset,
CRecordVector<UInt64> &packSizes,
- CRecordVector<bool> &packCRCsDefined,
+ CBoolVector &packCRCsDefined,
CRecordVector<UInt32> &packCRCs,
CObjectVector<CFolder> &folders,
CRecordVector<CNum> &numUnpackStreamsInFolders,
CRecordVector<UInt64> &unpackSizes,
- CRecordVector<bool> &digestsDefined,
+ CBoolVector &digestsDefined,
CRecordVector<UInt32> &digests)
{
for (;;)
@@ -695,13 +773,13 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
)
{
CRecordVector<UInt64> packSizes;
- CRecordVector<bool> packCRCsDefined;
+ CBoolVector packCRCsDefined;
CRecordVector<UInt32> packCRCs;
CObjectVector<CFolder> folders;
CRecordVector<CNum> numUnpackStreamsInFolders;
CRecordVector<UInt64> unpackSizes;
- CRecordVector<bool> digestsDefined;
+ CBoolVector digestsDefined;
CRecordVector<UInt32> digests;
ReadStreamsInfo(NULL,
@@ -802,7 +880,7 @@ HRESULT CInArchive::ReadHeader(
}
CRecordVector<UInt64> unpackSizes;
- CRecordVector<bool> digestsDefined;
+ CBoolVector digestsDefined;
CRecordVector<UInt32> digests;
if (type == NID::kMainStreamsInfo)
@@ -852,9 +930,7 @@ HRESULT CInArchive::ReadHeader(
db.ArchiveInfo.FileInfoPopIDs.Add(NID::kCRC);
CBoolVector emptyStreamVector;
- emptyStreamVector.Reserve((int)numFiles);
- for (i = 0; i < numFiles; i++)
- emptyStreamVector.Add(false);
+ BoolVector_Fill_False(emptyStreamVector, (int)numFiles);
CBoolVector emptyFileVector;
CBoolVector antiFileVector;
CNum numEmptyStreams = 0;
@@ -901,13 +977,10 @@ HRESULT CInArchive::ReadHeader(
for (i = 0; i < (CNum)emptyStreamVector.Size(); i++)
if (emptyStreamVector[i])
numEmptyStreams++;
- emptyFileVector.Reserve(numEmptyStreams);
- antiFileVector.Reserve(numEmptyStreams);
- for (i = 0; i < numEmptyStreams; i++)
- {
- emptyFileVector.Add(false);
- antiFileVector.Add(false);
- }
+
+ BoolVector_Fill_False(emptyFileVector, numEmptyStreams);
+ BoolVector_Fill_False(antiFileVector, numEmptyStreams);
+
break;
}
case NID::kEmptyFile: ReadBoolVector(numEmptyStreams, emptyFileVector); break;
diff --git a/CPP/7zip/Archive/7z/7zIn.h b/CPP/7zip/Archive/7z/7zIn.h
index 86d0e339..09c51105 100755
--- a/CPP/7zip/Archive/7z/7zIn.h
+++ b/CPP/7zip/Archive/7z/7zIn.h
@@ -4,8 +4,10 @@
#define __7Z_IN_H
#include "../../../Common/MyCom.h"
-#include "../../IStream.h"
+
#include "../../IPassword.h"
+#include "../../IStream.h"
+
#include "../../Common/CreateCoder.h"
#include "../../Common/InBuffer.h"
@@ -167,12 +169,12 @@ private:
void ReadArchiveProperties(CInArchiveInfo &archiveInfo);
void GetNextFolderItem(CFolder &itemInfo);
void ReadHashDigests(int numItems,
- CRecordVector<bool> &digestsDefined, CRecordVector<UInt32> &digests);
+ CBoolVector &digestsDefined, CRecordVector<UInt32> &digests);
void ReadPackInfo(
UInt64 &dataOffset,
CRecordVector<UInt64> &packSizes,
- CRecordVector<bool> &packCRCsDefined,
+ CBoolVector &packCRCsDefined,
CRecordVector<UInt32> &packCRCs);
void ReadUnpackInfo(
@@ -183,19 +185,19 @@ private:
const CObjectVector<CFolder> &folders,
CRecordVector<CNum> &numUnpackStreamsInFolders,
CRecordVector<UInt64> &unpackSizes,
- CRecordVector<bool> &digestsDefined,
+ CBoolVector &digestsDefined,
CRecordVector<UInt32> &digests);
void ReadStreamsInfo(
const CObjectVector<CByteBuffer> *dataVector,
UInt64 &dataOffset,
CRecordVector<UInt64> &packSizes,
- CRecordVector<bool> &packCRCsDefined,
+ CBoolVector &packCRCsDefined,
CRecordVector<UInt32> &packCRCs,
CObjectVector<CFolder> &folders,
CRecordVector<CNum> &numUnpackStreamsInFolders,
CRecordVector<UInt64> &unpackSizes,
- CRecordVector<bool> &digestsDefined,
+ CBoolVector &digestsDefined,
CRecordVector<UInt32> &digests);
diff --git a/CPP/7zip/Archive/7z/7zItem.h b/CPP/7zip/Archive/7z/7zItem.h
index 763a159f..1c3068bb 100755
--- a/CPP/7zip/Archive/7z/7zItem.h
+++ b/CPP/7zip/Archive/7z/7zItem.h
@@ -5,7 +5,9 @@
#include "../../../Common/Buffer.h"
#include "../../../Common/MyString.h"
+
#include "../../Common/MethodId.h"
+
#include "7zHeader.h"
namespace NArchive {
@@ -18,7 +20,7 @@ const CNum kNumNoIndex = 0xFFFFFFFF;
struct CCoderInfo
{
CMethodId MethodID;
- CByteBuffer Properties;
+ CByteBuffer Props;
CNum NumInStreams;
CNum NumOutStreams;
bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); }
@@ -80,6 +82,8 @@ struct CFolder
return i;
return -1;
}
+
+ bool CheckStructure() const;
};
struct CUInt64DefVector
diff --git a/CPP/7zip/Archive/7z/7zOut.cpp b/CPP/7zip/Archive/7z/7zOut.cpp
index dae242a6..7ac3c18c 100755
--- a/CPP/7zip/Archive/7z/7zOut.cpp
+++ b/CPP/7zip/Archive/7z/7zOut.cpp
@@ -278,7 +278,7 @@ void COutArchive::WriteFolder(const CFolder &folder)
{
const CCoderInfo &coder = folder.Coders[i];
{
- size_t propertiesSize = coder.Properties.GetCapacity();
+ size_t propsSize = coder.Props.GetCapacity();
UInt64 id = coder.MethodID;
int idSize;
@@ -292,7 +292,7 @@ void COutArchive::WriteFolder(const CFolder &folder)
b = (Byte)(idSize & 0xF);
bool isComplex = !coder.IsSimpleCoder();
b |= (isComplex ? 0x10 : 0);
- b |= ((propertiesSize != 0) ? 0x20 : 0 );
+ b |= ((propsSize != 0) ? 0x20 : 0 );
WriteByte(b);
WriteBytes(longID, idSize);
if (isComplex)
@@ -300,10 +300,10 @@ void COutArchive::WriteFolder(const CFolder &folder)
WriteNumber(coder.NumInStreams);
WriteNumber(coder.NumOutStreams);
}
- if (propertiesSize == 0)
+ if (propsSize == 0)
continue;
- WriteNumber(propertiesSize);
- WriteBytes(coder.Properties, propertiesSize);
+ WriteNumber(propsSize);
+ WriteBytes(coder.Props, propsSize);
}
}
for (i = 0; i < folder.BindPairs.Size(); i++)
diff --git a/CPP/7zip/Archive/7z/7zUpdate.cpp b/CPP/7zip/Archive/7z/7zUpdate.cpp
index d3039d49..0285b189 100755
--- a/CPP/7zip/Archive/7z/7zUpdate.cpp
+++ b/CPP/7zip/Archive/7z/7zUpdate.cpp
@@ -1,18 +1,19 @@
-// UpdateMain.cpp
+// 7zUpdate.cpp
#include "StdAfx.h"
-#include "7zUpdate.h"
-#include "7zFolderInStream.h"
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "../Common/ItemNameUtils.h"
+
#include "7zEncode.h"
+#include "7zFolderInStream.h"
#include "7zHandler.h"
#include "7zOut.h"
-
-#include "../../Compress/Copy/CopyCoder.h"
-#include "../../Common/ProgressUtils.h"
-#include "../../Common/LimitedStreams.h"
-#include "../../Common/LimitedStreams.h"
-#include "../Common/ItemNameUtils.h"
+#include "7zUpdate.h"
namespace NArchive {
namespace N7z {
@@ -78,7 +79,7 @@ static int CompareCoders(const CCoderInfo &c1, const CCoderInfo &c2)
RINOZ(MyCompare(c1.NumInStreams, c2.NumInStreams));
RINOZ(MyCompare(c1.NumOutStreams, c2.NumOutStreams));
RINOZ(MyCompare(c1.MethodID, c2.MethodID));
- return CompareBuffers(c1.Properties, c2.Properties);
+ return CompareBuffers(c1.Props, c2.Props);
}
static int CompareBindPairs(const CBindPair &b1, const CBindPair &b2)
@@ -336,28 +337,28 @@ static bool MakeExeMethod(const CCompressionMethodMode &method,
if (!GetMethodFull(k_LZMA, 1, methodFull))
return false;
{
- CProp property;
- property.Id = NCoderPropID::kAlgorithm;
- property.Value = kAlgorithmForBCJ2_LZMA;
- methodFull.Properties.Add(property);
+ CProp prop;
+ prop.Id = NCoderPropID::kAlgorithm;
+ prop.Value = kAlgorithmForBCJ2_LZMA;
+ methodFull.Props.Add(prop);
}
{
- CProp property;
- property.Id = NCoderPropID::kMatchFinder;
- property.Value = kMatchFinderForBCJ2_LZMA;
- methodFull.Properties.Add(property);
+ CProp prop;
+ prop.Id = NCoderPropID::kMatchFinder;
+ prop.Value = kMatchFinderForBCJ2_LZMA;
+ methodFull.Props.Add(prop);
}
{
- CProp property;
- property.Id = NCoderPropID::kDictionarySize;
- property.Value = kDictionaryForBCJ2_LZMA;
- methodFull.Properties.Add(property);
+ CProp prop;
+ prop.Id = NCoderPropID::kDictionarySize;
+ prop.Value = kDictionaryForBCJ2_LZMA;
+ methodFull.Props.Add(prop);
}
{
- CProp property;
- property.Id = NCoderPropID::kNumFastBytes;
- property.Value = kNumFastBytesForBCJ2_LZMA;
- methodFull.Properties.Add(property);
+ CProp prop;
+ prop.Id = NCoderPropID::kNumFastBytes;
+ prop.Value = kNumFastBytesForBCJ2_LZMA;
+ methodFull.Props.Add(prop);
}
exeMethod.Methods.Add(methodFull);
diff --git a/CPP/7zip/Archive/ArjHandler.cpp b/CPP/7zip/Archive/ArjHandler.cpp
index 9b12ed31..c40cbbcd 100755
--- a/CPP/7zip/Archive/ArjHandler.cpp
+++ b/CPP/7zip/Archive/ArjHandler.cpp
@@ -16,11 +16,9 @@
#include "../Common/StreamObjects.h"
#include "../Common/StreamUtils.h"
-#include "../Compress/Arj/ArjDecoder1.h"
-#include "../Compress/Arj/ArjDecoder2.h"
-#include "../Compress/Copy/CopyCoder.h"
-
-#include "IArchive.h"
+#include "../Compress/ArjDecoder1.h"
+#include "../Compress/ArjDecoder2.h"
+#include "../Compress/CopyCoder.h"
#include "Common/ItemNameUtils.h"
#include "Common/OutStreamWithCRC.h"
@@ -427,7 +425,7 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItem &item)
/*
UInt32 extraData;
if ((header.Flags & NFileHeader::NFlags::kExtFile) != 0)
- extraData = GetUInt32FromMemLE(_block + pos);
+ extraData = GetUi32(_block + pos);
*/
RINOK(SkeepExtendedHeaders());
diff --git a/CPP/7zip/Archive/BZip2/BZip2Handler.cpp b/CPP/7zip/Archive/BZip2/BZip2Handler.cpp
index 30b75444..05716b62 100755
--- a/CPP/7zip/Archive/BZip2/BZip2Handler.cpp
+++ b/CPP/7zip/Archive/BZip2/BZip2Handler.cpp
@@ -3,13 +3,13 @@
#include "StdAfx.h"
#include "Common/ComTry.h"
-#include "Common/Defs.h"
+
#include "Windows/PropVariant.h"
-#include "Windows/Defs.h"
+#include "../../Common/CreateCoder.h"
#include "../../Common/ProgressUtils.h"
#include "../../Common/StreamUtils.h"
-#include "../../Common/CreateCoder.h"
+
#include "../Common/DummyOutStream.h"
#include "BZip2Handler.h"
diff --git a/CPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp b/CPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp
index fd93f179..71311c32 100755
--- a/CPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp
+++ b/CPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp
@@ -9,7 +9,7 @@
#include "Windows/PropVariant.h"
-#include "../../Compress/Copy/CopyCoder.h"
+#include "../../Compress/CopyCoder.h"
#include "../Common/ParseProperties.h"
diff --git a/CPP/7zip/Archive/Cab/CabHandler.cpp b/CPP/7zip/Archive/Cab/CabHandler.cpp
index f4a11afb..ad015aaf 100755
--- a/CPP/7zip/Archive/Cab/CabHandler.cpp
+++ b/CPP/7zip/Archive/Cab/CabHandler.cpp
@@ -2,27 +2,27 @@
#include "StdAfx.h"
-#include "Common/StringConvert.h"
-#include "Common/Defs.h"
-#include "Common/UTFConvert.h"
#include "Common/ComTry.h"
+#include "Common/Defs.h"
#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+#include "Common/UTFConvert.h"
#include "Windows/PropVariant.h"
#include "Windows/Time.h"
-#include "CabHandler.h"
-#include "CabBlockInStream.h"
-
#include "../../Common/ProgressUtils.h"
-#include "../../Compress/Copy/CopyCoder.h"
-#include "../../Compress/Deflate/DeflateDecoder.h"
-#include "../../Compress/Lzx/LzxDecoder.h"
-#include "../../Compress/Quantum/QuantumDecoder.h"
+#include "../../Compress/CopyCoder.h"
+#include "../../Compress/DeflateDecoder.h"
+#include "../../Compress/LzxDecoder.h"
+#include "../../Compress/QuantumDecoder.h"
#include "../Common/ItemNameUtils.h"
+#include "CabBlockInStream.h"
+#include "CabHandler.h"
+
using namespace NWindows;
namespace NArchive {
diff --git a/CPP/7zip/Archive/Chm/ChmHandler.cpp b/CPP/7zip/Archive/Chm/ChmHandler.cpp
index 9da64bce..03bff821 100755
--- a/CPP/7zip/Archive/Chm/ChmHandler.cpp
+++ b/CPP/7zip/Archive/Chm/ChmHandler.cpp
@@ -1,27 +1,26 @@
-// Chm/Handler.cpp
+// ChmHandler.cpp
#include "StdAfx.h"
-#include "Common/StringConvert.h"
+#include "Common/ComTry.h"
#include "Common/Defs.h"
+#include "Common/StringConvert.h"
#include "Common/UTFConvert.h"
-#include "Common/ComTry.h"
#include "Windows/PropVariant.h"
#include "Windows/Time.h"
#include "../../Common/LimitedStreams.h"
-#include "../../Common/StreamUtils.h"
#include "../../Common/ProgressUtils.h"
+#include "../../Common/StreamUtils.h"
-#include "../../Compress/Copy/CopyCoder.h"
-#include "../../Compress/Lzx/LzxDecoder.h"
+#include "../../Compress/CopyCoder.h"
+#include "../../Compress/LzxDecoder.h"
#include "../Common/ItemNameUtils.h"
#include "ChmHandler.h"
-
using namespace NWindows;
using namespace NTime;
diff --git a/CPP/7zip/Archive/Common/HandlerOut.cpp b/CPP/7zip/Archive/Common/HandlerOut.cpp
index 63899fe4..3e817beb 100755
--- a/CPP/7zip/Archive/Common/HandlerOut.cpp
+++ b/CPP/7zip/Archive/Common/HandlerOut.cpp
@@ -1,17 +1,21 @@
-// HandlerOutCommon.cpp
+// HandlerOut.cpp
#include "StdAfx.h"
-#include "HandlerOut.h"
-#include "../../../Windows/PropVariant.h"
#include "../../../Common/StringToInt.h"
-#include "../../ICoder.h"
-#include "../Common/ParseProperties.h"
+
+#include "../../../Windows/PropVariant.h"
#ifdef COMPRESS_MT
#include "../../../Windows/System.h"
#endif
+#include "../../ICoder.h"
+
+#include "../Common/ParseProperties.h"
+
+#include "HandlerOut.h"
+
using namespace NWindows;
namespace NArchive {
@@ -161,13 +165,13 @@ static int FindPropIdFromStringName(const UString &name)
static void SetOneMethodProp(COneMethodInfo &oneMethodInfo, PROPID propID,
const NWindows::NCOM::CPropVariant &value)
{
- for (int j = 0; j < oneMethodInfo.Properties.Size(); j++)
- if (oneMethodInfo.Properties[j].Id == propID)
+ for (int j = 0; j < oneMethodInfo.Props.Size(); j++)
+ if (oneMethodInfo.Props[j].Id == propID)
return;
- CProp property;
- property.Id = propID;
- property.Value = value;
- oneMethodInfo.Properties.Add(property);
+ CProp prop;
+ prop.Id = propID;
+ prop.Value = value;
+ oneMethodInfo.Props.Add(prop);
}
void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo
@@ -311,19 +315,16 @@ static void SplitParam(const UString &param, UString &name, UString &value)
HRESULT COutHandler::SetParam(COneMethodInfo &oneMethodInfo, const UString &name, const UString &value)
{
- CProp property;
- if (
- name.CompareNoCase(L"D") == 0 ||
- name.CompareNoCase(L"MEM") == 0)
+ CProp prop;
+ if (name.CompareNoCase(L"D") == 0 ||
+ name.CompareNoCase(L"MEM") == 0)
{
UInt32 dicSize;
RINOK(ParsePropDictionaryValue(value, dicSize));
- if (name.CompareNoCase(L"D") == 0)
- property.Id = NCoderPropID::kDictionarySize;
- else
- property.Id = NCoderPropID::kUsedMemorySize;
- property.Value = dicSize;
- oneMethodInfo.Properties.Add(property);
+ prop.Id = (name.CompareNoCase(L"D") == 0) ?
+ NCoderPropID::kDictionarySize :
+ NCoderPropID::kUsedMemorySize;
+ prop.Value = dicSize;
}
else
{
@@ -332,7 +333,7 @@ HRESULT COutHandler::SetParam(COneMethodInfo &oneMethodInfo, const UString &name
return E_INVALIDARG;
const CNameToPropID &nameToPropID = g_NameToPropID[index];
- property.Id = nameToPropID.PropID;
+ prop.Id = nameToPropID.PropID;
NCOM::CPropVariant propValue;
@@ -354,11 +355,10 @@ HRESULT COutHandler::SetParam(COneMethodInfo &oneMethodInfo, const UString &name
propValue = value;
}
- if (!ConvertProperty(propValue, nameToPropID.VarType, property.Value))
+ if (!ConvertProperty(propValue, nameToPropID.VarType, prop.Value))
return E_INVALIDARG;
-
- oneMethodInfo.Properties.Add(property);
}
+ oneMethodInfo.Props.Add(prop);
return S_OK;
}
@@ -576,14 +576,13 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
}
else
{
- CProp property;
+ CProp prop;
if (realName.Left(1).CompareNoCase(L"D") == 0)
{
UInt32 dicSize;
RINOK(ParsePropDictionaryValue(realName.Mid(1), value, dicSize));
- property.Id = NCoderPropID::kDictionarySize;
- property.Value = dicSize;
- oneMethodInfo.Properties.Add(property);
+ prop.Id = NCoderPropID::kDictionarySize;
+ prop.Value = dicSize;
if (number <= mainDicMethodIndex)
mainDicSize = dicSize;
}
@@ -591,17 +590,15 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
{
UInt32 blockSize;
RINOK(ParsePropDictionaryValue(realName.Mid(1), value, blockSize));
- property.Id = NCoderPropID::kBlockSize;
- property.Value = blockSize;
- oneMethodInfo.Properties.Add(property);
+ prop.Id = NCoderPropID::kBlockSize;
+ prop.Value = blockSize;
}
else if (realName.Left(3).CompareNoCase(L"MEM") == 0)
{
UInt32 dicSize;
RINOK(ParsePropDictionaryValue(realName.Mid(3), value, dicSize));
- property.Id = NCoderPropID::kUsedMemorySize;
- property.Value = dicSize;
- oneMethodInfo.Properties.Add(property);
+ prop.Id = NCoderPropID::kUsedMemorySize;
+ prop.Value = dicSize;
if (number <= mainDicMethodIndex)
mainDicSize = dicSize;
}
@@ -610,15 +607,12 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
int index = FindPropIdFromStringName(realName);
if (index < 0)
return E_INVALIDARG;
-
const CNameToPropID &nameToPropID = g_NameToPropID[index];
- property.Id = nameToPropID.PropID;
-
- if (!ConvertProperty(value, nameToPropID.VarType, property.Value))
+ prop.Id = nameToPropID.PropID;
+ if (!ConvertProperty(value, nameToPropID.VarType, prop.Value))
return E_INVALIDARG;
-
- oneMethodInfo.Properties.Add(property);
}
+ oneMethodInfo.Props.Add(prop);
}
return S_OK;
}
diff --git a/CPP/7zip/Archive/Common/HandlerOut.h b/CPP/7zip/Archive/Common/HandlerOut.h
index b6095a6b..89c81c1f 100755
--- a/CPP/7zip/Archive/Common/HandlerOut.h
+++ b/CPP/7zip/Archive/Common/HandlerOut.h
@@ -3,14 +3,14 @@
#ifndef __HANDLER_OUT_H
#define __HANDLER_OUT_H
-#include "../../Common/MethodProps.h"
#include "../../../Common/MyString.h"
+#include "../../Common/MethodProps.h"
namespace NArchive {
struct COneMethodInfo
{
- CObjectVector<CProp> Properties;
+ CObjectVector<CProp> Props;
UString MethodName;
};
diff --git a/CPP/7zip/Archive/Common/OutStreamWithCRC.h b/CPP/7zip/Archive/Common/OutStreamWithCRC.h
index 32870235..a034ee9b 100755
--- a/CPP/7zip/Archive/Common/OutStreamWithCRC.h
+++ b/CPP/7zip/Archive/Common/OutStreamWithCRC.h
@@ -1,7 +1,7 @@
// OutStreamWithCRC.h
-#ifndef __OUTSTREAMWITHCRC_H
-#define __OUTSTREAMWITHCRC_H
+#ifndef __OUT_STREAM_WITH_CRC_H
+#define __OUT_STREAM_WITH_CRC_H
#include "../../../Common/MyCom.h"
#include "../../IStream.h"
diff --git a/CPP/7zip/Archive/Common/OutStreamWithSha1.h b/CPP/7zip/Archive/Common/OutStreamWithSha1.h
index 6df23080..4eab42a7 100755
--- a/CPP/7zip/Archive/Common/OutStreamWithSha1.h
+++ b/CPP/7zip/Archive/Common/OutStreamWithSha1.h
@@ -1,14 +1,14 @@
// OutStreamWithSha1.h
-#ifndef __OUTSTREAMWITHSHA1_H
-#define __OUTSTREAMWITHSHA1_H
+#ifndef __OUT_STREAM_WITH_SHA1_H
+#define __OUT_STREAM_WITH_SHA1_H
#include "../../../Common/MyCom.h"
#include "../../IStream.h"
-#include "../../Crypto/Hash/Sha1.h"
+#include "../../Crypto/Sha1.h"
class COutStreamWithSha1:
diff --git a/CPP/7zip/Archive/Cpio/CpioHandler.cpp b/CPP/7zip/Archive/Cpio/CpioHandler.cpp
index e034c87b..d49c854f 100755
--- a/CPP/7zip/Archive/Cpio/CpioHandler.cpp
+++ b/CPP/7zip/Archive/Cpio/CpioHandler.cpp
@@ -1,25 +1,25 @@
-// Archive/cpio/Handler.cpp
+// CpioHandler.cpp
#include "StdAfx.h"
-#include "CpioHandler.h"
-#include "CpioIn.h"
-
+#include "Common/ComTry.h"
#include "Common/Defs.h"
-#include "Common/StringConvert.h"
#include "Common/NewHandler.h"
-#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
-#include "Windows/Time.h"
#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+#include "../../Common/LimitedStreams.h"
#include "../../Common/ProgressUtils.h"
-#include "../../Common//LimitedStreams.h"
-#include "../../Compress/Copy/CopyCoder.h"
+#include "../../Compress/CopyCoder.h"
#include "../Common/ItemNameUtils.h"
+#include "CpioHandler.h"
+#include "CpioIn.h"
+
using namespace NWindows;
using namespace NTime;
diff --git a/CPP/7zip/Archive/DebHandler.cpp b/CPP/7zip/Archive/DebHandler.cpp
index 9bac2b7d..cf0c383f 100755
--- a/CPP/7zip/Archive/DebHandler.cpp
+++ b/CPP/7zip/Archive/DebHandler.cpp
@@ -16,7 +16,7 @@
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"
-#include "../Compress/Copy/CopyCoder.h"
+#include "../Compress/CopyCoder.h"
#include "Common/ItemNameUtils.h"
diff --git a/CPP/7zip/Archive/DmgHandler.cpp b/CPP/7zip/Archive/DmgHandler.cpp
index 7d5201c0..dd1e95ec 100755
--- a/CPP/7zip/Archive/DmgHandler.cpp
+++ b/CPP/7zip/Archive/DmgHandler.cpp
@@ -17,9 +17,9 @@
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"
-#include "../Compress/BZip2/BZip2Decoder.h"
-#include "../Compress/Copy/CopyCoder.h"
-#include "../Compress/Deflate/ZlibDecoder.h"
+#include "../Compress/BZip2Decoder.h"
+#include "../Compress/CopyCoder.h"
+#include "../Compress/ZlibDecoder.h"
// #define DMG_SHOW_RAW
diff --git a/CPP/7zip/Archive/ElfHandler.cpp b/CPP/7zip/Archive/ElfHandler.cpp
index 8d498177..cac7c3ad 100755
--- a/CPP/7zip/Archive/ElfHandler.cpp
+++ b/CPP/7zip/Archive/ElfHandler.cpp
@@ -15,7 +15,7 @@
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"
-#include "../Compress/Copy/CopyCoder.h"
+#include "../Compress/CopyCoder.h"
#include "Common/DummyOutStream.h"
diff --git a/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp b/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp
index 1fb1547d..bcbfc7e2 100755
--- a/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp
@@ -1,19 +1,20 @@
-// Archive/GZip/OutHandler.cpp
+// GZipHandlerOut.cpp
#include "StdAfx.h"
-#include "GZipHandler.h"
-#include "GZipUpdate.h"
-
#include "Common/StringConvert.h"
#include "Common/StringToInt.h"
-#include "Windows/Time.h"
#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../../Compress/CopyCoder.h"
-#include "../../Compress/Copy/CopyCoder.h"
#include "../Common/ParseProperties.h"
+#include "GZipHandler.h"
+#include "GZipUpdate.h"
+
using namespace NWindows;
using namespace NTime;
diff --git a/CPP/7zip/Archive/GZip/GZipUpdate.cpp b/CPP/7zip/Archive/GZip/GZipUpdate.cpp
index 8f8a2c4f..f3a4d331 100755
--- a/CPP/7zip/Archive/GZip/GZipUpdate.cpp
+++ b/CPP/7zip/Archive/GZip/GZipUpdate.cpp
@@ -2,8 +2,6 @@
#include "StdAfx.h"
-#include "GZipUpdate.h"
-
#include "Common/Defs.h"
#include "Common/StringConvert.h"
@@ -11,12 +9,16 @@
#include "Windows/PropVariant.h"
#include "../../ICoder.h"
-#include "../../Common/ProgressUtils.h"
+
#include "../../Common/CreateCoder.h"
-#include "../../Compress/Copy/CopyCoder.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../../Compress/CopyCoder.h"
#include "../Common/InStreamWithCRC.h"
+#include "GZipUpdate.h"
+
namespace NArchive {
namespace NGZip {
diff --git a/CPP/7zip/Archive/Iso/IsoHandler.cpp b/CPP/7zip/Archive/Iso/IsoHandler.cpp
index db1b9c06..f0c926c4 100755
--- a/CPP/7zip/Archive/Iso/IsoHandler.cpp
+++ b/CPP/7zip/Archive/Iso/IsoHandler.cpp
@@ -1,25 +1,25 @@
-// Iso/Handler.cpp
+// IsoHandler.cpp
#include "StdAfx.h"
-#include "IsoHandler.h"
-
+#include "Common/ComTry.h"
#include "Common/Defs.h"
-#include "Common/StringConvert.h"
#include "Common/IntToString.h"
#include "Common/NewHandler.h"
-#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
-#include "Windows/Time.h"
#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
-#include "../../Common/ProgressUtils.h"
#include "../../Common/LimitedStreams.h"
+#include "../../Common/ProgressUtils.h"
-#include "../../Compress/Copy/CopyCoder.h"
+#include "../../Compress/CopyCoder.h"
#include "../Common/ItemNameUtils.h"
+#include "IsoHandler.h"
+
using namespace NWindows;
using namespace NTime;
diff --git a/CPP/7zip/Archive/Lzh/LzhHandler.cpp b/CPP/7zip/Archive/Lzh/LzhHandler.cpp
index ee43a3b0..66153f7a 100755
--- a/CPP/7zip/Archive/Lzh/LzhHandler.cpp
+++ b/CPP/7zip/Archive/Lzh/LzhHandler.cpp
@@ -2,23 +2,23 @@
#include "StdAfx.h"
+#include "Common/ComTry.h"
#include "Common/Defs.h"
#include "Common/StringConvert.h"
-#include "Common/ComTry.h"
-#include "Windows/Time.h"
#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
#include "LzhHandler.h"
#include "LzhOutStreamWithCRC.h"
#include "../../ICoder.h"
-#include "../../Common/ProgressUtils.h"
#include "../../Common/LimitedStreams.h"
+#include "../../Common/ProgressUtils.h"
-#include "../../Compress/Copy/CopyCoder.h"
-#include "../../Compress/Lzh/LzhDecoder.h"
+#include "../../Compress/CopyCoder.h"
+#include "../../Compress/LzhDecoder.h"
#include "../Common/ItemNameUtils.h"
@@ -384,5 +384,4 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
COM_TRY_END
}
-
}}
diff --git a/CPP/7zip/Archive/MachoHandler.cpp b/CPP/7zip/Archive/MachoHandler.cpp
index bbae3150..f3ccadf5 100755
--- a/CPP/7zip/Archive/MachoHandler.cpp
+++ b/CPP/7zip/Archive/MachoHandler.cpp
@@ -14,7 +14,7 @@
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"
-#include "../Compress/Copy/CopyCoder.h"
+#include "../Compress/CopyCoder.h"
#include "Common/DummyOutStream.h"
diff --git a/CPP/7zip/Archive/MubHandler.cpp b/CPP/7zip/Archive/MubHandler.cpp
index edf00f93..25c3815e 100755
--- a/CPP/7zip/Archive/MubHandler.cpp
+++ b/CPP/7zip/Archive/MubHandler.cpp
@@ -13,7 +13,7 @@
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"
-#include "../Compress/Copy/CopyCoder.h"
+#include "../Compress/CopyCoder.h"
#define Get32(p) GetBe32(p)
diff --git a/CPP/7zip/Archive/PeHandler.cpp b/CPP/7zip/Archive/PeHandler.cpp
index 7031db97..70af37c7 100755
--- a/CPP/7zip/Archive/PeHandler.cpp
+++ b/CPP/7zip/Archive/PeHandler.cpp
@@ -16,7 +16,7 @@
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"
-#include "../Compress/Copy/CopyCoder.h"
+#include "../Compress/CopyCoder.h"
#include "Common/DummyOutStream.h"
@@ -605,7 +605,11 @@ HRESULT CHandler::LoadDebugSections(IInStream *stream, bool &thereIsSection)
}
}
if (i == _sections.Size())
- return S_FALSE;
+ {
+ return S_OK;
+ // Exe for ARM requires S_OK
+ // return S_FALSE;
+ }
CByteBuffer buffer;
buffer.SetCapacity(debugLink.Size);
diff --git a/CPP/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp
index e81c7967..2431e449 100755
--- a/CPP/7zip/Archive/Rar/RarHandler.cpp
+++ b/CPP/7zip/Archive/Rar/RarHandler.cpp
@@ -2,25 +2,29 @@
#include "StdAfx.h"
-#include "RarHandler.h"
-
-#include "Common/StringConvert.h"
#include "Common/ComTry.h"
#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
#include "Windows/PropVariant.h"
#include "Windows/Time.h"
#include "../../IPassword.h"
-#include "../../Common/ProgressUtils.h"
+
#include "../../Common/CreateCoder.h"
-#include "../../Common/MethodId.h"
#include "../../Common/FilterCoder.h"
-#include "../../Compress/Copy/CopyCoder.h"
-#include "../../Crypto/Rar20/Rar20Cipher.h"
-#include "../../Crypto/RarAES/RarAES.h"
-#include "../Common/OutStreamWithCRC.h"
+#include "../../Common/MethodId.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "../../Crypto/Rar20Crypto.h"
+#include "../../Crypto/RarAes.h"
+
#include "../Common/ItemNameUtils.h"
+#include "../Common/OutStreamWithCRC.h"
+
+#include "RarHandler.h"
using namespace NWindows;
using namespace NTime;
diff --git a/CPP/7zip/Archive/Rar/RarIn.h b/CPP/7zip/Archive/Rar/RarIn.h
index 7be3f53c..ff97a109 100755
--- a/CPP/7zip/Archive/Rar/RarIn.h
+++ b/CPP/7zip/Archive/Rar/RarIn.h
@@ -5,10 +5,14 @@
#include "Common/DynamicBuffer.h"
#include "Common/MyCom.h"
-#include "../../IStream.h"
+
#include "../../ICoder.h"
+#include "../../IStream.h"
+
#include "../../Common/StreamObjects.h"
-#include "../../Crypto/RarAES/RarAES.h"
+
+#include "../../Crypto/RarAes.h"
+
#include "RarHeader.h"
#include "RarItem.h"
diff --git a/CPP/7zip/Archive/RpmHandler.cpp b/CPP/7zip/Archive/RpmHandler.cpp
index f39ee3c5..c6951799 100755
--- a/CPP/7zip/Archive/RpmHandler.cpp
+++ b/CPP/7zip/Archive/RpmHandler.cpp
@@ -13,7 +13,7 @@
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"
-#include "../Compress/Copy/CopyCoder.h"
+#include "../Compress/CopyCoder.h"
using namespace NWindows;
diff --git a/CPP/7zip/Archive/Split/SplitHandler.cpp b/CPP/7zip/Archive/Split/SplitHandler.cpp
index 380e6ce3..61b7f4a7 100755
--- a/CPP/7zip/Archive/Split/SplitHandler.cpp
+++ b/CPP/7zip/Archive/Split/SplitHandler.cpp
@@ -1,22 +1,24 @@
-// Tar/Handler.cpp
+// SplitHandler.cpp
#include "StdAfx.h"
-#include "SplitHandler.h"
-
+#include "Common/ComTry.h"
#include "Common/Defs.h"
-#include "Common/StringConvert.h"
#include "Common/NewHandler.h"
-#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
-#include "Windows/Time.h"
#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
#include "../../Common/ProgressUtils.h"
-#include "../../Compress/Copy/CopyCoder.h"
+
+#include "../../Compress/CopyCoder.h"
+
#include "../Common/ItemNameUtils.h"
#include "../Common/MultiStream.h"
+#include "SplitHandler.h"
+
using namespace NWindows;
using namespace NTime;
diff --git a/CPP/7zip/Archive/Tar/TarHandler.cpp b/CPP/7zip/Archive/Tar/TarHandler.cpp
index f70f7e4e..f8000c85 100755
--- a/CPP/7zip/Archive/Tar/TarHandler.cpp
+++ b/CPP/7zip/Archive/Tar/TarHandler.cpp
@@ -1,26 +1,26 @@
-// Tar/Handler.cpp
+// TarHandler.cpp
#include "StdAfx.h"
-#include "TarHandler.h"
-#include "TarIn.h"
-
+#include "Common/ComTry.h"
#include "Common/Defs.h"
-#include "Common/StringConvert.h"
#include "Common/NewHandler.h"
-#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
-#include "Windows/Time.h"
#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
-#include "../../Common/ProgressUtils.h"
#include "../../Common/LimitedStreams.h"
-#include "../Common/DummyOutStream.h"
+#include "../../Common/ProgressUtils.h"
-#include "../../Compress/Copy/CopyCoder.h"
+#include "../../Compress/CopyCoder.h"
+#include "../Common/DummyOutStream.h"
#include "../Common/ItemNameUtils.h"
+#include "TarHandler.h"
+#include "TarIn.h"
+
using namespace NWindows;
namespace NArchive {
diff --git a/CPP/7zip/Archive/Tar/TarUpdate.cpp b/CPP/7zip/Archive/Tar/TarUpdate.cpp
index 62c6bff6..1c048915 100755
--- a/CPP/7zip/Archive/Tar/TarUpdate.cpp
+++ b/CPP/7zip/Archive/Tar/TarUpdate.cpp
@@ -2,13 +2,10 @@
#include "StdAfx.h"
-#include "Common/Defs.h"
-#include "Common/StringConvert.h"
-#include "Windows/Defs.h"
-
-#include "../../Common/ProgressUtils.h"
#include "../../Common/LimitedStreams.h"
-#include "../../Compress/Copy/CopyCoder.h"
+#include "../../Common/ProgressUtils.h"
+
+#include "../../Compress/CopyCoder.h"
#include "TarOut.h"
#include "TarUpdate.h"
diff --git a/CPP/7zip/Archive/Udf/UdfHandler.cpp b/CPP/7zip/Archive/Udf/UdfHandler.cpp
index e503e843..12329147 100755
--- a/CPP/7zip/Archive/Udf/UdfHandler.cpp
+++ b/CPP/7zip/Archive/Udf/UdfHandler.cpp
@@ -1,19 +1,21 @@
-// Udf/Handler.cpp
+// UdfHandler.cpp
#include "StdAfx.h"
-#include "UdfHandler.h"
-
-#include "Common/NewHandler.h"
#include "Common/ComTry.h"
+#include "Common/NewHandler.h"
-#include "Windows/Time.h"
#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
#include "../../Common/ProgressUtils.h"
-#include "../../Compress/Copy/CopyCoder.h"
+
+#include "../../Compress/CopyCoder.h"
+
#include "../Common/DummyOutStream.h"
+#include "UdfHandler.h"
+
namespace NArchive {
namespace NUdf {
diff --git a/CPP/7zip/Archive/Wim/WimIn.cpp b/CPP/7zip/Archive/Wim/WimIn.cpp
index 5c741f8f..121e33ab 100755
--- a/CPP/7zip/Archive/Wim/WimIn.cpp
+++ b/CPP/7zip/Archive/Wim/WimIn.cpp
@@ -123,7 +123,7 @@ HRESULT CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outS
{
try { return CodeReal(inStream, outStream, outSize); }
catch(const CInBufferException &e) { return e.ErrorCode; } \
- catch(const CLZOutWindowException &e) { return e.ErrorCode; }
+ catch(const CLzOutWindowException &e) { return e.ErrorCode; }
catch(...) { return S_FALSE; }
}
diff --git a/CPP/7zip/Archive/Wim/WimIn.h b/CPP/7zip/Archive/Wim/WimIn.h
index 79e7bd01..e51a301a 100755
--- a/CPP/7zip/Archive/Wim/WimIn.h
+++ b/CPP/7zip/Archive/Wim/WimIn.h
@@ -3,11 +3,11 @@
#ifndef __ARCHIVE_WIM_IN_H
#define __ARCHIVE_WIM_IN_H
-#include "Common/MyString.h"
#include "Common/Buffer.h"
+#include "Common/MyString.h"
-#include "../../Compress/Lzx/LzxDecoder.h"
-#include "../../Compress/Copy/CopyCoder.h"
+#include "../../Compress/CopyCoder.h"
+#include "../../Compress/LzxDecoder.h"
namespace NArchive {
namespace NWim {
@@ -66,7 +66,7 @@ const UInt32 kMainTableSize = 256 + kNumPosLenSlots;
class CDecoder
{
CBitStream m_InBitStream;
- CLZOutWindow m_OutWindowStream;
+ CLzOutWindow m_OutWindowStream;
NCompress::NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
HRESULT CodeSpec(UInt32 size);
diff --git a/CPP/7zip/Archive/XarHandler.cpp b/CPP/7zip/Archive/XarHandler.cpp
index 1069d15d..2dddad9f 100755
--- a/CPP/7zip/Archive/XarHandler.cpp
+++ b/CPP/7zip/Archive/XarHandler.cpp
@@ -18,9 +18,9 @@
#include "../Common/StreamObjects.h"
#include "../Common/StreamUtils.h"
-#include "../Compress/BZip2/BZip2Decoder.h"
-#include "../Compress/Copy/CopyCoder.h"
-#include "../Compress/Deflate/ZlibDecoder.h"
+#include "../Compress/BZip2Decoder.h"
+#include "../Compress/CopyCoder.h"
+#include "../Compress/ZlibDecoder.h"
#include "Common/OutStreamWithSha1.h"
diff --git a/CPP/7zip/Archive/ZHandler.cpp b/CPP/7zip/Archive/ZHandler.cpp
index bc006eda..21432b22 100755
--- a/CPP/7zip/Archive/ZHandler.cpp
+++ b/CPP/7zip/Archive/ZHandler.cpp
@@ -10,7 +10,7 @@
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"
-#include "../Compress/Z/ZDecoder.h"
+#include "../Compress/ZDecoder.h"
#include "Common/DummyOutStream.h"
diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
index 9010a5e4..212a8b4b 100755
--- a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
+++ b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
@@ -1,4 +1,4 @@
-// AddCommon.cpp
+// ZipAddCommon.cpp
#include "StdAfx.h"
@@ -8,14 +8,17 @@ extern "C"
}
#include "Windows/PropVariant.h"
-#include "Windows/Defs.h"
-#include "../../MyVersion.h"
+
#include "../../ICoder.h"
#include "../../IPassword.h"
+#include "../../MyVersion.h"
+
#include "../../Common/CreateCoder.h"
#include "../../Common/StreamObjects.h"
#include "../../Common/StreamUtils.h"
-#include "../../Compress/LZMA/LZMAEncoder.h"
+
+#include "../../Compress/LzmaEncoder.h"
+
#include "../Common/InStreamWithCRC.h"
#include "ZipAddCommon.h"
@@ -34,7 +37,7 @@ class CLzmaEncoder:
public ICompressCoder,
public CMyUnknownImp
{
- NCompress::NLZMA::CEncoder *EncoderSpec;
+ NCompress::NLzma::CEncoder *EncoderSpec;
CMyComPtr<ICompressCoder> Encoder;
Byte Header[kLzmaHeaderSize];
public:
@@ -49,7 +52,7 @@ HRESULT CLzmaEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIAN
{
if (!Encoder)
{
- EncoderSpec = new NCompress::NLZMA::CEncoder;
+ EncoderSpec = new NCompress::NLzma::CEncoder;
Encoder = EncoderSpec;
}
CSequentialOutStreamImp *outStreamSpec = new CSequentialOutStreamImp;
@@ -153,7 +156,7 @@ HRESULT CAddCommon::Compress(
}
if (_options.IsAesMode)
{
- _cryptoStreamSpec->Filter = _aesFilter = _filterAesSpec = new NCrypto::NWzAES::CEncoder;
+ _cryptoStreamSpec->Filter = _aesFilter = _filterAesSpec = new NCrypto::NWzAes::CEncoder;
_filterAesSpec->SetKeyMode(_options.AesKeyMode);
RINOK(_filterAesSpec->CryptoSetPassword(
(const Byte *)(const char *)_options.Password, _options.Password.Length()));
diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.h b/CPP/7zip/Archive/Zip/ZipAddCommon.h
index 6c766037..8f5b568d 100755
--- a/CPP/7zip/Archive/Zip/ZipAddCommon.h
+++ b/CPP/7zip/Archive/Zip/ZipAddCommon.h
@@ -1,16 +1,18 @@
-// Zip/AddCommon.h
+// ZipAddCommon.h
-#ifndef __ZIP_ADDCOMMON_H
-#define __ZIP_ADDCOMMON_H
+#ifndef __ZIP_ADD_COMMON_H
+#define __ZIP_ADD_COMMON_H
#include "../../ICoder.h"
#include "../../IProgress.h"
-#include "../../Compress/Copy/CopyCoder.h"
#include "../../Common/CreateCoder.h"
#include "../../Common/FilterCoder.h"
-#include "../../Crypto/Zip/ZipCipher.h"
-#include "../../Crypto/WzAES/WzAES.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "../../Crypto/ZipCrypto.h"
+#include "../../Crypto/WzAes.h"
#include "ZipCompressionMode.h"
@@ -38,7 +40,7 @@ class CAddCommon
CMyComPtr<ISequentialOutStream> _cryptoStream;
NCrypto::NZip::CEncoder *_filterSpec;
- NCrypto::NWzAES::CEncoder *_filterAesSpec;
+ NCrypto::NWzAes::CEncoder *_filterAesSpec;
CMyComPtr<ICompressFilter> _zipCryptoFilter;
CMyComPtr<ICompressFilter> _aesFilter;
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp
index 40d131f0..3054ae02 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp
@@ -2,40 +2,35 @@
#include "StdAfx.h"
-#include "ZipHandler.h"
-
-#include "Common/Defs.h"
-#include "Common/StringConvert.h"
#include "Common/ComTry.h"
+#include "Common/Defs.h"
#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
-#include "Windows/Time.h"
#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
#include "../../IPassword.h"
+#include "../../Common/CreateCoder.h"
+#include "../../Common/FilterCoder.h"
#include "../../Common/ProgressUtils.h"
#include "../../Common/StreamObjects.h"
#include "../../Common/StreamUtils.h"
-#include "../../Common/CreateCoder.h"
-#include "../../Common/FilterCoder.h"
-#include "../../Compress/Copy/CopyCoder.h"
-#include "../../Compress/LZMA/LZMADecoder.h"
+#include "../../Compress/CopyCoder.h"
+#include "../../Compress/LzmaDecoder.h"
+#include "../../Compress/ImplodeDecoder.h"
+#include "../../Compress/ShrinkDecoder.h"
+
+#include "../../Crypto/WzAes.h"
+#include "../../Crypto/ZipCrypto.h"
+#include "../../Crypto/ZipStrong.h"
#include "../Common/ItemNameUtils.h"
#include "../Common/OutStreamWithCRC.h"
-#include "../../Compress/Shrink/ShrinkDecoder.h"
-#include "../../Compress/Implode/ImplodeDecoder.h"
-
-
-#include "../../Crypto/Zip/ZipCipher.h"
-#include "../../Crypto/WzAES/WzAES.h"
-
-#ifdef ZIP_STRONG_SUPORT
-#include "../../Crypto/ZipStrong/ZipStrong.h"
-#endif
+#include "ZipHandler.h"
using namespace NWindows;
@@ -381,7 +376,7 @@ class CLzmaDecoder:
public ICompressCoder,
public CMyUnknownImp
{
- NCompress::NLZMA::CDecoder *DecoderSpec;
+ NCompress::NLzma::CDecoder *DecoderSpec;
CMyComPtr<ICompressCoder> Decoder;
public:
CLzmaDecoder();
@@ -393,7 +388,7 @@ public:
CLzmaDecoder::CLzmaDecoder()
{
- DecoderSpec = new NCompress::NLZMA::CDecoder;
+ DecoderSpec = new NCompress::NLzma::CDecoder;
Decoder = DecoderSpec;
}
@@ -417,20 +412,24 @@ struct CMethodItem
class CZipDecoder
{
NCrypto::NZip::CDecoder *_zipCryptoDecoderSpec;
- NCrypto::NWzAES::CDecoder *_aesDecoderSpec;
+ NCrypto::NZipStrong::CDecoder *_pkAesDecoderSpec;
+ NCrypto::NWzAes::CDecoder *_wzAesDecoderSpec;
+
CMyComPtr<ICompressFilter> _zipCryptoDecoder;
- CMyComPtr<ICompressFilter> _aesDecoder;
- #ifdef ZIP_STRONG_SUPORT
- NCrypto::NZipStrong::CDecoder *_zsDecoderSpec;
- CMyComPtr<ICompressFilter> _zsDecoder;
- #endif
+ CMyComPtr<ICompressFilter> _pkAesDecoder;
+ CMyComPtr<ICompressFilter> _wzAesDecoder;
+
CFilterCoder *filterStreamSpec;
CMyComPtr<ISequentialInStream> filterStream;
CMyComPtr<ICryptoGetTextPassword> getTextPassword;
CObjectVector<CMethodItem> methodItems;
public:
- CZipDecoder(): _zipCryptoDecoderSpec(0), _aesDecoderSpec(0), filterStreamSpec(0) {}
+ CZipDecoder():
+ _zipCryptoDecoderSpec(0),
+ _pkAesDecoderSpec(0),
+ _wzAesDecoderSpec(0),
+ filterStreamSpec(0) {}
HRESULT Decode(
DECL_EXTERNAL_CODECS_LOC_VARS
@@ -453,23 +452,19 @@ HRESULT CZipDecoder::Decode(
CInStreamReleaser inStreamReleaser;
bool needCRC = true;
- bool aesMode = false;
- #ifdef ZIP_STRONG_SUPORT
+ bool wzAesMode = false;
bool pkAesMode = false;
- #endif
UInt16 methodId = item.CompressionMethod;
if (item.IsEncrypted())
{
if (item.IsStrongEncrypted())
{
- #ifdef ZIP_STRONG_SUPORT
CStrongCryptoField f;
if (item.CentralExtra.GetStrongCryptoField(f))
{
pkAesMode = true;
}
if (!pkAesMode)
- #endif
{
res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
return S_OK;
@@ -480,7 +475,7 @@ HRESULT CZipDecoder::Decode(
CWzAesExtraField aesField;
if (item.CentralExtra.GetWzAesField(aesField))
{
- aesMode = true;
+ wzAesMode = true;
needCRC = aesField.NeedCrc();
}
}
@@ -496,11 +491,11 @@ HRESULT CZipDecoder::Decode(
CMyComPtr<ISequentialInStream> inStream;
{
UInt64 packSize = item.PackSize;
- if (aesMode)
+ if (wzAesMode)
{
- if (packSize < NCrypto::NWzAES::kMacSize)
+ if (packSize < NCrypto::NWzAes::kMacSize)
return S_OK;
- packSize -= NCrypto::NWzAES::kMacSize;
+ packSize -= NCrypto::NWzAes::kMacSize;
}
UInt64 dataPos = item.GetDataPosition();
inStream.Attach(archive.CreateLimitedStream(dataPos, packSize));
@@ -510,32 +505,30 @@ HRESULT CZipDecoder::Decode(
CMyComPtr<ICompressFilter> cryptoFilter;
if (item.IsEncrypted())
{
- if (aesMode)
+ if (wzAesMode)
{
CWzAesExtraField aesField;
if (!item.CentralExtra.GetWzAesField(aesField))
return S_OK;
methodId = aesField.Method;
- if (!_aesDecoder)
+ if (!_wzAesDecoder)
{
- _aesDecoderSpec = new NCrypto::NWzAES::CDecoder;
- _aesDecoder = _aesDecoderSpec;
+ _wzAesDecoderSpec = new NCrypto::NWzAes::CDecoder;
+ _wzAesDecoder = _wzAesDecoderSpec;
}
- cryptoFilter = _aesDecoder;
+ cryptoFilter = _wzAesDecoder;
Byte properties = aesField.Strength;
- RINOK(_aesDecoderSpec->SetDecoderProperties2(&properties, 1));
+ RINOK(_wzAesDecoderSpec->SetDecoderProperties2(&properties, 1));
}
- #ifdef ZIP_STRONG_SUPORT
else if (pkAesMode)
{
- if (!_zsDecoder)
+ if (!_pkAesDecoder)
{
- _zsDecoderSpec = new NCrypto::NZipStrong::CDecoder;
- _zsDecoder = _zsDecoderSpec;
+ _pkAesDecoderSpec = new NCrypto::NZipStrong::CDecoder;
+ _pkAesDecoder = _pkAesDecoderSpec;
}
- cryptoFilter = _zsDecoder;
+ cryptoFilter = _pkAesDecoder;
}
- #endif
else
{
if (!_zipCryptoDecoder)
@@ -556,11 +549,7 @@ HRESULT CZipDecoder::Decode(
CMyComBSTR password;
RINOK(getTextPassword->CryptoGetTextPassword(&password));
AString charPassword;
- if (aesMode
- #ifdef ZIP_STRONG_SUPORT
- || pkAesMode
- #endif
- )
+ if (wzAesMode || pkAesMode)
{
charPassword = UnicodeStringToMultiByte((const wchar_t *)password, CP_ACP);
/*
@@ -583,9 +572,9 @@ HRESULT CZipDecoder::Decode(
// we use OEM. WinZip/Windows probably use ANSI for some files
charPassword = UnicodeStringToMultiByte((const wchar_t *)password, CP_OEMCP);
}
- HRESULT res = cryptoSetPassword->CryptoSetPassword(
+ HRESULT result = cryptoSetPassword->CryptoSetPassword(
(const Byte *)(const char *)charPassword, charPassword.Length());
- if (res != S_OK)
+ if (result != S_OK)
return S_OK;
}
else
@@ -660,7 +649,7 @@ HRESULT CZipDecoder::Decode(
#endif
{
- HRESULT result;
+ HRESULT result = S_OK;
CMyComPtr<ISequentialInStream> inStreamNew;
if (item.IsEncrypted())
{
@@ -670,33 +659,42 @@ HRESULT CZipDecoder::Decode(
filterStream = filterStreamSpec;
}
filterStreamSpec->Filter = cryptoFilter;
- if (aesMode)
+ if (wzAesMode)
{
- RINOK(_aesDecoderSpec->ReadHeader(inStream));
+ result = _wzAesDecoderSpec->ReadHeader(inStream);
+ if (result == S_OK)
+ {
+ if (!_wzAesDecoderSpec->CheckPasswordVerifyCode())
+ result = S_FALSE;
+ }
}
- #ifdef ZIP_STRONG_SUPORT
else if (pkAesMode)
{
- RINOK(_zsDecoderSpec->ReadHeader(inStream));
+ result =_pkAesDecoderSpec->ReadHeader(inStream, item.FileCRC, item.UnPackSize);
+ if (result == S_OK)
+ {
+ bool passwOK;
+ result = _pkAesDecoderSpec->CheckPassword(passwOK);
+ if (result == S_OK && !passwOK)
+ result = S_FALSE;
+ }
}
- #endif
else
{
- RINOK(_zipCryptoDecoderSpec->ReadHeader(inStream));
+ result = _zipCryptoDecoderSpec->ReadHeader(inStream);
}
- RINOK(filterStreamSpec->SetInStream(inStream));
- inStreamReleaser.FilterCoder = filterStreamSpec;
- inStreamNew = filterStream;
-
- if (aesMode)
+
+ if (result == S_OK)
{
- if (!_aesDecoderSpec->CheckPasswordVerifyCode())
- return S_OK;
+ RINOK(filterStreamSpec->SetInStream(inStream));
+ inStreamReleaser.FilterCoder = filterStreamSpec;
+ inStreamNew = filterStream;
}
}
else
inStreamNew = inStream;
- result = coder->Code(inStreamNew, outStream, NULL, &item.UnPackSize, compressProgress);
+ if (result == S_OK)
+ result = coder->Code(inStreamNew, outStream, NULL, &item.UnPackSize, compressProgress);
if (result == S_FALSE)
return S_OK;
if (result == E_NOTIMPL)
@@ -711,10 +709,10 @@ HRESULT CZipDecoder::Decode(
bool authOk = true;
if (needCRC)
crcOK = (outStreamSpec->GetCRC() == item.FileCRC);
- if (aesMode)
+ if (wzAesMode)
{
- inStream.Attach(archive.CreateLimitedStream(authenticationPos, NCrypto::NWzAES::kMacSize));
- if (_aesDecoderSpec->CheckMac(inStream, authOk) != S_OK)
+ inStream.Attach(archive.CreateLimitedStream(authenticationPos, NCrypto::NWzAes::kMacSize));
+ if (_wzAesDecoderSpec->CheckMac(inStream, authOk) != S_OK)
authOk = false;
}
diff --git a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
index ea46e131..fe2c16e7 100755
--- a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
@@ -1,22 +1,25 @@
-// Zip/HandlerOut.cpp
+// ZipHandlerOut.cpp
#include "StdAfx.h"
-#include "ZipHandler.h"
-#include "ZipUpdate.h"
-
-#include "Common/StringConvert.h"
#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
#include "Common/StringToInt.h"
#include "Windows/PropVariant.h"
#include "Windows/Time.h"
#include "../../IPassword.h"
+
+#include "../../Common/OutBuffer.h"
+
+#include "../../Crypto/WzAes.h"
+
#include "../Common/ItemNameUtils.h"
#include "../Common/ParseProperties.h"
-#include "../../Crypto/WzAES/WzAES.h"
-#include "../../Common/OutBuffer.h"
+
+#include "ZipHandler.h"
+#include "ZipUpdate.h"
using namespace NWindows;
using namespace NCOM;
@@ -253,7 +256,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
return E_INVALIDARG;
if (m_IsAesMode)
{
- if (options.Password.Length() > NCrypto::NWzAES::kPasswordSizeMax)
+ if (options.Password.Length() > NCrypto::NWzAes::kPasswordSizeMax)
return E_INVALIDARG;
}
options.Password = UnicodeStringToMultiByte((const wchar_t *)password, CP_OEMCP);
diff --git a/CPP/7zip/Archive/Zip/ZipUpdate.cpp b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
index b10f801e..5c7e64db 100755
--- a/CPP/7zip/Archive/Zip/ZipUpdate.cpp
+++ b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
@@ -2,27 +2,26 @@
#include "StdAfx.h"
-#include <stdio.h>
-
-#include "ZipUpdate.h"
-#include "ZipAddCommon.h"
-#include "ZipOut.h"
-
-#include "Common/Defs.h"
#include "Common/AutoPtr.h"
+#include "Common/Defs.h"
#include "Common/StringConvert.h"
+
#include "Windows/Defs.h"
#include "Windows/Thread.h"
+#include "../../Common/CreateCoder.h"
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/OutMemStream.h"
#include "../../Common/ProgressUtils.h"
#ifdef COMPRESS_MT
#include "../../Common/ProgressMt.h"
#endif
-#include "../../Common/LimitedStreams.h"
-#include "../../Common/OutMemStream.h"
-#include "../../Common/CreateCoder.h"
-#include "../../Compress/Copy/CopyCoder.h"
+#include "../../Compress/CopyCoder.h"
+
+#include "ZipAddCommon.h"
+#include "ZipOut.h"
+#include "ZipUpdate.h"
using namespace NWindows;
using namespace NSynchronization;