diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2010-06-20 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:03 +0300 |
commit | e279500d76f1944ba26526f085030909a2c7ef49 (patch) | |
tree | 130291a48634b2918c6749be8ea360d15e1e202b /CPP/7zip/Archive | |
parent | 708873490ee36691d84cc06336aac87c5129f8a0 (diff) |
9.159.15
Diffstat (limited to 'CPP/7zip/Archive')
-rwxr-xr-x | CPP/7zip/Archive/7z/7zExtract.cpp | 43 | ||||
-rwxr-xr-x | CPP/7zip/Archive/ArchiveExports.cpp | 2 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Cab/CabHandler.cpp | 28 | ||||
-rwxr-xr-x | CPP/7zip/Archive/FatHandler.cpp | 4 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Wim/WimHandler.cpp | 5 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Wim/WimHandlerOut.cpp | 10 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Wim/WimIn.cpp | 7 |
7 files changed, 53 insertions, 46 deletions
diff --git a/CPP/7zip/Archive/7z/7zExtract.cpp b/CPP/7zip/Archive/7z/7zExtract.cpp index eb3ee502..d55f38e1 100755 --- a/CPP/7zip/Archive/7z/7zExtract.cpp +++ b/CPP/7zip/Archive/7z/7zExtract.cpp @@ -2,15 +2,14 @@ #include "StdAfx.h" -#include "7zHandler.h" -#include "7zFolderOutStream.h" -#include "7zDecode.h" -// #include "7z1Decode.h" - #include "../../../Common/ComTry.h" -#include "../../Common/StreamObjects.h" + #include "../../Common/ProgressUtils.h" -#include "../../Common/LimitedStreams.h" + +#include "7zDecode.h" +// #include "7z1Decode.h" +#include "7zFolderOutStream.h" +#include "7zHandler.h" namespace NArchive { namespace N7z { @@ -73,13 +72,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, */ CObjectVector<CExtractFolderInfo> extractFolderInfoVector; - for(UInt32 ii = 0; ii < numItems; ii++) + for (UInt32 ii = 0; ii < numItems; ii++) { // UInt32 fileIndex = allFilesMode ? indexIndex : indices[indexIndex]; UInt32 ref2Index = allFilesMode ? ii : indices[ii]; // const CRef2 &ref2 = _refs[ref2Index]; - // for(UInt32 ri = 0; ri < ref2.Refs.Size(); ri++) + // for (UInt32 ri = 0; ri < ref2.Refs.Size(); ri++) { #ifdef _7Z_VOL // const CRef &ref = ref2.Refs[ri]; @@ -149,27 +148,26 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, ); // CDecoder1 decoder; - UInt64 currentTotalPacked = 0; - UInt64 currentTotalUnpacked = 0; - UInt64 totalFolderUnpacked; - UInt64 totalFolderPacked; + UInt64 totalPacked = 0; + UInt64 totalUnpacked = 0; + UInt64 curPacked, curUnpacked; CLocalProgress *lps = new CLocalProgress; CMyComPtr<ICompressProgressInfo> progress = lps; lps->Init(extractCallback, false); - for(int i = 0; i < extractFolderInfoVector.Size(); i++, - currentTotalUnpacked += totalFolderUnpacked, - currentTotalPacked += totalFolderPacked) + for (int i = 0;; i++, totalUnpacked += curUnpacked, totalPacked += curPacked) { - lps->OutSize = currentTotalUnpacked; - lps->InSize = currentTotalPacked; + lps->OutSize = totalUnpacked; + lps->InSize = totalPacked; RINOK(lps->SetCur()); + + if (i >= extractFolderInfoVector.Size()) + break; const CExtractFolderInfo &efi = extractFolderInfoVector[i]; - totalFolderUnpacked = efi.UnpackSize; - - totalFolderPacked = 0; + curUnpacked = efi.UnpackSize; + curPacked = 0; CFolderOutStream *folderOutStream = new CFolderOutStream; CMyComPtr<ISequentialOutStream> outStream(folderOutStream); @@ -187,7 +185,6 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, else startIndex = db.FolderStartFileIndex[efi.FolderIndex]; - HRESULT result = folderOutStream->Init(&db, #ifdef _7Z_VOL volume.StartRef2Index, @@ -205,7 +202,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, CNum folderIndex = efi.FolderIndex; const CFolder &folderInfo = db.Folders[folderIndex]; - totalFolderPacked = _db.GetFolderFullPackSize(folderIndex); + curPacked = _db.GetFolderFullPackSize(folderIndex); CNum packStreamIndex = db.FolderStartPackStreamIndex[folderIndex]; UInt64 folderStartPackPos = db.GetFolderStreamPos(folderIndex, 0); diff --git a/CPP/7zip/Archive/ArchiveExports.cpp b/CPP/7zip/Archive/ArchiveExports.cpp index 5dcf9806..c7908b59 100755 --- a/CPP/7zip/Archive/ArchiveExports.cpp +++ b/CPP/7zip/Archive/ArchiveExports.cpp @@ -85,6 +85,7 @@ STDAPI CreateArchiver(const GUID *clsid, const GUID *iid, void **outObject) STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value) { + COM_TRY_BEGIN if (formatIndex >= g_NumArcs) return E_INVALIDARG; const CArcInfo &arc = *g_Arcs[formatIndex]; @@ -119,6 +120,7 @@ STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value } prop.Detach(value); return S_OK; + COM_TRY_END } STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value) diff --git a/CPP/7zip/Archive/Cab/CabHandler.cpp b/CPP/7zip/Archive/Cab/CabHandler.cpp index 9fb91423..20f670d3 100755 --- a/CPP/7zip/Archive/Cab/CabHandler.cpp +++ b/CPP/7zip/Archive/Cab/CabHandler.cpp @@ -41,7 +41,7 @@ enum }; #endif -STATPROPSTG kProps[] = +static STATPROPSTG kProps[] = { { NULL, kpidPath, VT_BSTR}, { NULL, kpidSize, VT_UI8}, @@ -57,18 +57,18 @@ STATPROPSTG kProps[] = #endif }; -static const wchar_t *kMethods[] = +static const char *kMethods[] = { - L"None", - L"MSZip", - L"Quantum", - L"LZX" + "None", + "MSZip", + "Quantum", + "LZX" }; static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]); -static const wchar_t *kUnknownMethod = L"Unknown"; +static const char *kUnknownMethod = "Unknown"; -STATPROPSTG kArcProps[] = +static STATPROPSTG kArcProps[] = { { NULL, kpidMethod, VT_BSTR}, // { NULL, kpidSolid, VT_BOOL}, @@ -87,7 +87,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) { case kpidMethod: { - UString resString; + AString resString; CRecordVector<Byte> ids; int i; for (int v = 0; v < m_Database.Volumes.Size(); v++) @@ -99,9 +99,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) for (i = 0; i < ids.Size(); i++) { Byte id = ids[i]; - UString method = (id < kNumMethods) ? kMethods[id] : kUnknownMethod; + AString method = (id < kNumMethods) ? kMethods[id] : kUnknownMethod; if (!resString.IsEmpty()) - resString += L' '; + resString += ' '; resString += method; } prop = resString; @@ -171,12 +171,12 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va UInt32 realFolderIndex = item.GetFolderIndex(db.Folders.Size()); const CFolder &folder = db.Folders[realFolderIndex]; int methodIndex = folder.GetCompressionMethod(); - UString method = (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod; + AString method = (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod; if (methodIndex == NHeader::NCompressionMethodMajor::kLZX || methodIndex == NHeader::NCompressionMethodMajor::kQuantum) { - method += L":"; - wchar_t temp[32]; + method += ':'; + char temp[32]; ConvertUInt64ToString(folder.CompressionTypeMinor, temp); method += temp; } diff --git a/CPP/7zip/Archive/FatHandler.cpp b/CPP/7zip/Archive/FatHandler.cpp index 6d7b249c..22a61f88 100755 --- a/CPP/7zip/Archive/FatHandler.cpp +++ b/CPP/7zip/Archive/FatHandler.cpp @@ -578,8 +578,12 @@ HRESULT CDatabase::Open() return S_FALSE; UInt64 fileSize; RINOK(InStream->Seek(0, STREAM_SEEK_END, &fileSize)); + + /* we comment that check to support truncated images */ + /* if (fileSize < Header.GetPhySize()) return S_FALSE; + */ if (Header.IsFat32()) { diff --git a/CPP/7zip/Archive/Wim/WimHandler.cpp b/CPP/7zip/Archive/Wim/WimHandler.cpp index 8092a34c..9bea60dd 100755 --- a/CPP/7zip/Archive/Wim/WimHandler.cpp +++ b/CPP/7zip/Archive/Wim/WimHandler.cpp @@ -391,7 +391,6 @@ STDMETHODIMP CHandler::Open(IInStream *inStream, { COM_TRY_BEGIN Close(); - try { CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback; @@ -488,10 +487,6 @@ STDMETHODIMP CHandler::Open(IInStream *inStream, _xmlInComments = (_xmls.Size() == 1 && !_db.ShowImageNumber); } - catch(...) - { - return S_FALSE; - } return S_OK; COM_TRY_END } diff --git a/CPP/7zip/Archive/Wim/WimHandlerOut.cpp b/CPP/7zip/Archive/Wim/WimHandlerOut.cpp index d51eb81a..c7eb9980 100755 --- a/CPP/7zip/Archive/Wim/WimHandlerOut.cpp +++ b/CPP/7zip/Archive/Wim/WimHandlerOut.cpp @@ -258,7 +258,7 @@ static size_t WriteItem(const CUpdateItem &item, Byte *p, const Byte *hash) return totalLen; } -void WriteTree(const CDir &tree, CRecordVector<CSha1Hash> &digests, +static void WriteTree(const CDir &tree, CRecordVector<CSha1Hash> &digests, CUpdateItem &defaultDirItem, CObjectVector<CUpdateItem> &updateItems, Byte *dest, size_t &pos) { @@ -488,11 +488,15 @@ static HRESULT UpdateArchive(ISequentialOutStream *seqOutStream, const UInt32 kSecuritySize = 8; size_t pos = kSecuritySize; WriteTree(rootFolder, hashes.Digests, ri, updateItems, NULL, pos); + CByteBuffer meta; meta.SetCapacity(pos); - // memset(meta, 0, kSecuritySize); - Set32((Byte *)meta, 0); // only if there is no security data, we can use 0 here. + + // we can write 0 here only if there is no security data, imageX does it, + // but some programs expect size = 8 + Set32((Byte *)meta, 8); // size of security data Set32((Byte *)meta + 4, 0); // num security entries + pos = kSecuritySize; WriteTree(rootFolder, hashes.Digests, ri, updateItems, (Byte *)meta, pos); diff --git a/CPP/7zip/Archive/Wim/WimIn.cpp b/CPP/7zip/Archive/Wim/WimIn.cpp index b65b4c44..4ea028af 100755 --- a/CPP/7zip/Archive/Wim/WimIn.cpp +++ b/CPP/7zip/Archive/Wim/WimIn.cpp @@ -384,7 +384,12 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent) return S_FALSE; UInt32 fileNameLen = Get16(p + 0x24); - if ((fileNameLen & 1) != 0 || ((0x26 + fileNameLen + 6) & ~7) != len) + if ((fileNameLen & 1) != 0) + return S_FALSE; + /* Probably different versions of ImageX can use different number of + additional ZEROs. So we don't use exact check. */ + UInt32 fileNameLen2 = (fileNameLen == 0 ? fileNameLen : fileNameLen + 2); + if (((0x26 + fileNameLen2 + 6) & ~7) > len) return S_FALSE; UString name; |