mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 12:07:03 -06:00
16.01
This commit is contained in:
committed by
Kornel Lesiński
parent
66ac98bb02
commit
bec3b479dc
@@ -154,7 +154,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
case kpidBlock:
|
||||
if (m_Database.LowLevel)
|
||||
prop = item.Section;
|
||||
else if (item.Section != 0)
|
||||
else if (item.Section != 0 && item.Section < m_Database.Sections.Size())
|
||||
prop = m_Database.GetFolder(index);
|
||||
break;
|
||||
|
||||
@@ -545,7 +545,11 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
currentTotalSize += item.Size;
|
||||
continue;
|
||||
}
|
||||
const CSectionInfo §ion = m_Database.Sections[(unsigned)item.Section];
|
||||
|
||||
if (sectionIndex >= m_Database.Sections.Size())
|
||||
continue;
|
||||
|
||||
const CSectionInfo §ion = m_Database.Sections[(unsigned)sectionIndex];
|
||||
if (section.IsLzx())
|
||||
{
|
||||
const CLzxInfo &lzxInfo = section.Methods[0].LzxInfo;
|
||||
@@ -621,6 +625,18 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sectionIndex >= m_Database.Sections.Size())
|
||||
{
|
||||
// we must report error here;
|
||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
|
||||
if (!testMode && !realOutStream)
|
||||
continue;
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kHeadersError));
|
||||
continue;
|
||||
}
|
||||
|
||||
const CSectionInfo §ion = m_Database.Sections[(unsigned)sectionIndex];
|
||||
|
||||
if (!section.IsLzx())
|
||||
|
||||
@@ -667,13 +667,15 @@ static int CompareFiles(const unsigned *p1, const unsigned *p2, void *param)
|
||||
return -1;
|
||||
if (isDir2)
|
||||
{
|
||||
if (isDir1)
|
||||
return MyCompare(*p1, *p2);
|
||||
return 1;
|
||||
if (!isDir1)
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOZ(MyCompare(item1.Section, item2.Section));
|
||||
RINOZ(MyCompare(item1.Offset, item2.Offset));
|
||||
RINOZ(MyCompare(item1.Size, item2.Size));
|
||||
}
|
||||
RINOZ(MyCompare(item1.Section, item2.Section));
|
||||
RINOZ(MyCompare(item1.Offset, item2.Offset));
|
||||
RINOZ(MyCompare(item1.Size, item2.Size));
|
||||
return MyCompare(*p1, *p2);
|
||||
}
|
||||
|
||||
@@ -716,6 +718,19 @@ bool CFilesDatabase::Check()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFilesDatabase::CheckSectionRefs()
|
||||
{
|
||||
FOR_VECTOR (i, Indices)
|
||||
{
|
||||
const CItem &item = Items[Indices[i]];
|
||||
if (item.Section == 0 || item.IsDir())
|
||||
continue;
|
||||
if (item.Section >= Sections.Size())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int inline GetLog(UInt32 num)
|
||||
{
|
||||
for (int i = 0; i < 32; i++)
|
||||
@@ -745,10 +760,10 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned i;
|
||||
for (i = 1; i < database.Sections.Size(); i++)
|
||||
unsigned si;
|
||||
for (si = 1; si < database.Sections.Size(); si++)
|
||||
{
|
||||
CSectionInfo §ion = database.Sections[i];
|
||||
CSectionInfo §ion = database.Sections[si];
|
||||
AString sectionPrefix = GetSectionPrefix(section.Name);
|
||||
{
|
||||
// Content
|
||||
@@ -993,6 +1008,8 @@ HRESULT CInArchive::Open2(IInStream *inStream,
|
||||
return S_OK;
|
||||
}
|
||||
RINOK(res);
|
||||
if (!database.CheckSectionRefs())
|
||||
HeadersError = true;
|
||||
database.LowLevel = false;
|
||||
}
|
||||
catch(...)
|
||||
|
||||
@@ -186,18 +186,24 @@ public:
|
||||
UInt64 GetFolder(unsigned fileIndex) const
|
||||
{
|
||||
const CItem &item = Items[Indices[fileIndex]];
|
||||
const CSectionInfo §ion = Sections[(unsigned)item.Section];
|
||||
if (section.IsLzx())
|
||||
return section.Methods[0].LzxInfo.GetFolder(item.Offset);
|
||||
if (item.Section < Sections.Size())
|
||||
{
|
||||
const CSectionInfo §ion = Sections[(unsigned)item.Section];
|
||||
if (section.IsLzx())
|
||||
return section.Methods[0].LzxInfo.GetFolder(item.Offset);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
UInt64 GetLastFolder(unsigned fileIndex) const
|
||||
{
|
||||
const CItem &item = Items[Indices[fileIndex]];
|
||||
const CSectionInfo §ion = Sections[(unsigned)item.Section];
|
||||
if (section.IsLzx())
|
||||
return section.Methods[0].LzxInfo.GetFolder(item.Offset + item.Size - 1);
|
||||
if (item.Section < Sections.Size())
|
||||
{
|
||||
const CSectionInfo §ion = Sections[(unsigned)item.Section];
|
||||
if (section.IsLzx())
|
||||
return section.Methods[0].LzxInfo.GetFolder(item.Offset + item.Size - 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -217,6 +223,7 @@ public:
|
||||
void SetIndices();
|
||||
void Sort();
|
||||
bool Check();
|
||||
bool CheckSectionRefs();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user