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>2009-02-03 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:59 +0300
commit8874e4fbc9faabdcff719b9b2ac8ebad4f282bbe (patch)
tree4180f817b3d10dc34cde8b7ccc8c589eae4b26d3 /CPP/7zip/Archive
parent1dc92281fa580c11a79fef9fc862a6ce354a76ac (diff)
4.654.65
Diffstat (limited to 'CPP/7zip/Archive')
-rwxr-xr-xCPP/7zip/Archive/Common/HandlerOut.cpp2
-rwxr-xr-xCPP/7zip/Archive/DebHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/MachoHandler.cpp8
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisHandler.cpp34
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisIn.h48
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandlerOut.cpp19
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipItem.h1
8 files changed, 60 insertions, 56 deletions
diff --git a/CPP/7zip/Archive/Common/HandlerOut.cpp b/CPP/7zip/Archive/Common/HandlerOut.cpp
index 3e817beb..76739e94 100755
--- a/CPP/7zip/Archive/Common/HandlerOut.cpp
+++ b/CPP/7zip/Archive/Common/HandlerOut.cpp
@@ -586,7 +586,7 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
if (number <= mainDicMethodIndex)
mainDicSize = dicSize;
}
- else if (realName.Left(1).CompareNoCase(L"B") == 0)
+ else if (realName.Left(1).CompareNoCase(L"C") == 0)
{
UInt32 blockSize;
RINOK(ParsePropDictionaryValue(realName.Mid(1), value, blockSize));
diff --git a/CPP/7zip/Archive/DebHandler.cpp b/CPP/7zip/Archive/DebHandler.cpp
index cf0c383f..fc962df3 100755
--- a/CPP/7zip/Archive/DebHandler.cpp
+++ b/CPP/7zip/Archive/DebHandler.cpp
@@ -198,7 +198,7 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
RINOK(GetNextItemReal(filled, item));
if (!filled)
return S_OK;
- if (item.Name.CompareNoCase("debian-binary") != 0)
+ if (item.Name.Compare("debian-binary") != 0)
return S_OK;
if (item.Size != 4)
return S_OK;
diff --git a/CPP/7zip/Archive/MachoHandler.cpp b/CPP/7zip/Archive/MachoHandler.cpp
index f3ccadf5..76f63a21 100755
--- a/CPP/7zip/Archive/MachoHandler.cpp
+++ b/CPP/7zip/Archive/MachoHandler.cpp
@@ -308,11 +308,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
static AString GetName(const char *name)
{
- AString res;
- char *p = res.GetBuffer(kNameSize);
- strncpy(p, name, kNameSize);
- p[kNameSize] = 0;
- res.ReleaseBuffer();
+ char res[kNameSize + 1];
+ memcpy(res, name, kNameSize);
+ res[kNameSize] = 0;
return res;
}
diff --git a/CPP/7zip/Archive/Nsis/NsisHandler.cpp b/CPP/7zip/Archive/Nsis/NsisHandler.cpp
index b8945130..f2e3aab6 100755
--- a/CPP/7zip/Archive/Nsis/NsisHandler.cpp
+++ b/CPP/7zip/Archive/Nsis/NsisHandler.cpp
@@ -2,19 +2,19 @@
#include "StdAfx.h"
-#include "NsisHandler.h"
+#include "../../../../C/CpuArch.h"
-#include "Common/StringConvert.h"
+#include "Common/ComTry.h"
#include "Common/IntToString.h"
#include "Common/NewHandler.h"
-#include "Common/ComTry.h"
#include "Windows/PropVariant.h"
-#include "../Common/ItemNameUtils.h"
#include "../../Common/StreamUtils.h"
-#include "../../../../C/CpuArch.h"
+#include "../Common/ItemNameUtils.h"
+
+#include "NsisHandler.h"
#define Get32(p) GetUi32(p)
@@ -228,12 +228,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
{
case kpidPath:
{
- UString s;
- if (_archive.IsUnicode)
- s = item.GetReducedNameU();
- else
- s = MultiByteToUnicodeString(item.GetReducedNameA(), CP_ACP);
- s = NItemName::WinNameToOSName(s);
+ UString s = NItemName::WinNameToOSName(item.GetReducedName(_archive.IsUnicode));
if (!s.IsEmpty())
prop = (const wchar_t *)s;
break;
@@ -320,6 +315,11 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
_inStream, _archive.Method, _archive.FilterFlag, useFilter));
}
+ CByteBuffer byteBuf;
+ const UInt32 kBufferLength = 1 << 16;
+ byteBuf.SetCapacity(kBufferLength);
+ Byte *buffer = byteBuf;
+
bool dataError = false;
for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
{
@@ -363,9 +363,6 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
bool sizeIsKnown = false;
UInt32 fullSize = 0;
- const UInt32 kBufferLength = 1 << 11;
- Byte buffer[kBufferLength];
-
if (_archive.IsSolid)
{
UInt64 pos = _archive.GetPosOfSolidItem(index);
@@ -389,12 +386,13 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
}
if (streamPos == pos)
{
+ Byte buffer2[4];
size_t processedSize = 4;
- RINOK(_archive.Decoder.Read(buffer, &processedSize));
+ RINOK(_archive.Decoder.Read(buffer2, &processedSize));
if (processedSize != 4)
return E_FAIL;
streamPos += processedSize;
- fullSize = Get32(buffer);
+ fullSize = Get32(buffer2);
sizeIsKnown = true;
needDecompress = true;
}
@@ -409,7 +407,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(_archive.Decoder.Init(
EXTERNAL_CODECS_VARS
_inStream, _archive.Method, _archive.FilterFlag, useFilter));
- fullSize = Get32(buffer);
+ // fullSize = Get32(buffer); // It's bug !!!
+ // Test it: what is exact fullSize?
+ fullSize = 0xFFFFFFFF;
}
else
fullSize = item.Size;
diff --git a/CPP/7zip/Archive/Nsis/NsisIn.h b/CPP/7zip/Archive/Nsis/NsisIn.h
index 4257b687..1fa6b4a6 100755
--- a/CPP/7zip/Archive/Nsis/NsisIn.h
+++ b/CPP/7zip/Archive/Nsis/NsisIn.h
@@ -3,16 +3,17 @@
#ifndef __ARCHIVE_NSIS_IN_H
#define __ARCHIVE_NSIS_IN_H
-#include "Common/MyCom.h"
-#include "Common/IntToString.h"
#include "Common/Buffer.h"
+#include "Common/IntToString.h"
+#include "Common/MyCom.h"
+#include "Common/StringConvert.h"
+
+#include "../../Common/CreateCoder.h"
#include "../../IStream.h"
#include "NsisDecode.h"
-#include "../../Common/CreateCoder.h"
-
// #define NSIS_SCRIPT
namespace NArchive {
@@ -81,32 +82,25 @@ struct CItem
return (PrefixA.Length() >= 3 || PrefixU.Length() >= 3);
}
- AString GetReducedNameA() const
- {
- AString prefix = PrefixA;
- if (prefix.Length() > 0)
- if (prefix[prefix.Length() - 1] != '\\')
- prefix += '\\';
- AString s2 = prefix + NameA;
- const int len = 9;
- if (s2.Left(len).CompareNoCase("$INSTDIR\\") == 0)
- s2 = s2.Mid(len);
- return s2;
- }
-
- UString GetReducedNameU() const
+ UString GetReducedName(bool unicode) const
{
- UString prefix = PrefixU;
- if (prefix.Length() > 0)
- if (prefix[prefix.Length() - 1] != L'\\')
- prefix += L'\\';
- UString s2 = prefix + NameU;
+ UString s;
+ if (unicode)
+ s = PrefixU;
+ else
+ s = MultiByteToUnicodeString(PrefixA);
+ if (s.Length() > 0)
+ if (s[s.Length() - 1] != L'\\')
+ s += L'\\';
+ if (unicode)
+ s += NameU;
+ else
+ s += MultiByteToUnicodeString(NameA);
const int len = 9;
- if (s2.Left(len).CompareNoCase(L"$INSTDIR\\") == 0)
- s2 = s2.Mid(len);
- return s2;
+ if (s.Left(len).CompareNoCase(L"$INSTDIR\\") == 0)
+ s = s.Mid(len);
+ return s;
}
-
};
class CInArchive
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.h b/CPP/7zip/Archive/Zip/ZipHandler.h
index 09179111..1a3a441a 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.h
+++ b/CPP/7zip/Archive/Zip/ZipHandler.h
@@ -55,6 +55,7 @@ private:
UInt32 m_NumMatchFinderCycles;
bool m_NumMatchFinderCyclesDefined;
+ bool m_ForceAesMode;
bool m_IsAesMode;
Byte m_AesKeyMode;
@@ -78,6 +79,7 @@ private:
m_NumFastBytes =
m_NumMatchFinderCycles = 0xFFFFFFFF;
m_NumMatchFinderCyclesDefined = false;
+ m_ForceAesMode = false;
m_IsAesMode = false;
m_AesKeyMode = 3; // aes-256
m_WriteNtfsTimeExtra = false;
diff --git a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
index fe2c16e7..2f28d5ec 100755
--- a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
@@ -98,6 +98,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
{
COM_TRY_BEGIN2
CObjectVector<CUpdateItem> updateItems;
+ bool thereAreAesUpdates = false;
for (UInt32 i = 0; i < numItems; i++)
{
CUpdateItem ui;
@@ -111,7 +112,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
ui.NewData = IntToBool(newData);
ui.IndexInArchive = indexInArchive;
ui.IndexInClient = i;
- // bool existInArchive = (indexInArchive != UInt32(-1));
+ bool existInArchive = (indexInArchive != UInt32(-1));
+ if (existInArchive && newData)
+ if (m_Items[indexInArchive].IsAesEncrypted())
+ thereAreAesUpdates = true;
+
if (IntToBool(newProperties))
{
UString name;
@@ -237,7 +242,6 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
}
CMyComPtr<ICryptoGetTextPassword2> getTextPassword;
- if (!getTextPassword)
{
CMyComPtr<IArchiveUpdateCallback> udateCallBack2(callback);
udateCallBack2.QueryInterface(IID_ICryptoGetTextPassword2, &getTextPassword);
@@ -252,16 +256,17 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
options.PasswordIsDefined = IntToBool(passwordIsDefined);
if (options.PasswordIsDefined)
{
+ options.IsAesMode = (m_ForceAesMode ? m_IsAesMode : thereAreAesUpdates);
+ options.AesKeyMode = m_AesKeyMode;
+
if (!IsAsciiString((const wchar_t *)password))
return E_INVALIDARG;
- if (m_IsAesMode)
+ if (options.IsAesMode)
{
if (options.Password.Length() > NCrypto::NWzAes::kPasswordSizeMax)
return E_INVALIDARG;
}
options.Password = UnicodeStringToMultiByte((const wchar_t *)password, CP_OEMCP);
- options.IsAesMode = m_IsAesMode;
- options.AesKeyMode = m_AesKeyMode;
}
}
else
@@ -422,9 +427,13 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
else
return E_INVALIDARG;
m_IsAesMode = true;
+ m_ForceAesMode = true;
}
else if (valueString == L"ZIPCRYPTO")
+ {
m_IsAesMode = false;
+ m_ForceAesMode = true;
+ }
else
return E_INVALIDARG;
}
diff --git a/CPP/7zip/Archive/Zip/ZipItem.h b/CPP/7zip/Archive/Zip/ZipItem.h
index c41ba8c8..c0f780f8 100755
--- a/CPP/7zip/Archive/Zip/ZipItem.h
+++ b/CPP/7zip/Archive/Zip/ZipItem.h
@@ -187,6 +187,7 @@ public:
bool IsEncrypted() const { return (Flags & NFileHeader::NFlags::kEncrypted) != 0; }
bool IsStrongEncrypted() const { return IsEncrypted() && (Flags & NFileHeader::NFlags::kStrongEncrypted) != 0; };
+ bool IsAesEncrypted() const { return IsEncrypted() && (IsStrongEncrypted() || CompressionMethod == NFileHeader::NCompressionMethod::kWzAES); };
bool IsLzmaEOS() const { return (Flags & NFileHeader::NFlags::kLzmaEOS) != 0; }