ChmIn.cpp (p7zip_15.14.1_src_all) | : | ChmIn.cpp (p7zip_16.02_src_all) | ||
---|---|---|---|---|
skipping to change at line 669 | skipping to change at line 669 | |||
{ | { | |||
const CObjectVector<CItem> &items = *(const CObjectVector<CItem> *)param; | const CObjectVector<CItem> &items = *(const CObjectVector<CItem> *)param; | |||
const CItem &item1 = items[*p1]; | const CItem &item1 = items[*p1]; | |||
const CItem &item2 = items[*p2]; | const CItem &item2 = items[*p2]; | |||
bool isDir1 = item1.IsDir(); | bool isDir1 = item1.IsDir(); | |||
bool isDir2 = item2.IsDir(); | bool isDir2 = item2.IsDir(); | |||
if (isDir1 && !isDir2) | if (isDir1 && !isDir2) | |||
return -1; | return -1; | |||
if (isDir2) | if (isDir2) | |||
{ | { | |||
if (isDir1) | if (!isDir1) | |||
return MyCompare(*p1, *p2); | return 1; | |||
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); | return MyCompare(*p1, *p2); | |||
} | } | |||
void CFilesDatabase::SetIndices() | void CFilesDatabase::SetIndices() | |||
{ | { | |||
FOR_VECTOR (i, Items) | FOR_VECTOR (i, Items) | |||
{ | { | |||
const CItem &item = Items[i]; | const CItem &item = Items[i]; | |||
if (item.IsUserItem() && item.Name.Len() != 1) | if (item.IsUserItem() && item.Name.Len() != 1) | |||
Indices.Add(i); | Indices.Add(i); | |||
skipping to change at line 718 | skipping to change at line 720 | |||
} | } | |||
if (item.Offset < maxPos) | if (item.Offset < maxPos) | |||
return false; | return false; | |||
maxPos = item.Offset + item.Size; | maxPos = item.Offset + item.Size; | |||
if (maxPos < item.Offset) | if (maxPos < item.Offset) | |||
return false; | return false; | |||
} | } | |||
return true; | 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) | static int inline GetLog(UInt32 num) | |||
{ | { | |||
for (int i = 0; i < 32; i++) | for (int i = 0; i < 32; i++) | |||
if (((UInt32)1 << i) == num) | if (((UInt32)1 << i) == num) | |||
return i; | return i; | |||
return -1; | return -1; | |||
} | } | |||
HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database) | HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database) | |||
{ | { | |||
skipping to change at line 747 | skipping to change at line 762 | |||
UString name; | UString name; | |||
ReadUString(nameLen, name); | ReadUString(nameLen, name); | |||
if (ReadUInt16() != 0) | if (ReadUInt16() != 0) | |||
return S_FALSE; | return S_FALSE; | |||
ConvertUnicodeToUTF8(name, section.Name); | ConvertUnicodeToUTF8(name, section.Name); | |||
// if (!ConvertUnicodeToUTF8(name, section.Name)) return S_FALSE; | // if (!ConvertUnicodeToUTF8(name, section.Name)) return S_FALSE; | |||
database.Sections.Add(section); | database.Sections.Add(section); | |||
} | } | |||
} | } | |||
unsigned i; | unsigned si; | |||
for (i = 1; i < database.Sections.Size(); i++) | for (si = 1; si < database.Sections.Size(); si++) | |||
{ | { | |||
CSectionInfo §ion = database.Sections[i]; | CSectionInfo §ion = database.Sections[si]; | |||
AString sectionPrefix = GetSectionPrefix(section.Name); | AString sectionPrefix = GetSectionPrefix(section.Name); | |||
{ | { | |||
// Content | // Content | |||
int index = database.FindItem(sectionPrefix + kContent); | int index = database.FindItem(sectionPrefix + kContent); | |||
if (index < 0) | if (index < 0) | |||
return S_FALSE; | return S_FALSE; | |||
const CItem &item = database.Items[index]; | const CItem &item = database.Items[index]; | |||
section.Offset = item.Offset; | section.Offset = item.Offset; | |||
section.CompressedSize = item.Size; | section.CompressedSize = item.Size; | |||
} | } | |||
skipping to change at line 994 | skipping to change at line 1009 | |||
try | try | |||
{ | { | |||
HRESULT res = OpenHighLevel(inStream, database); | HRESULT res = OpenHighLevel(inStream, database); | |||
if (res == S_FALSE) | if (res == S_FALSE) | |||
{ | { | |||
UnsupportedFeature = true; | UnsupportedFeature = true; | |||
database.HighLevelClear(); | database.HighLevelClear(); | |||
return S_OK; | return S_OK; | |||
} | } | |||
RINOK(res); | RINOK(res); | |||
if (!database.CheckSectionRefs()) | ||||
HeadersError = true; | ||||
database.LowLevel = false; | database.LowLevel = false; | |||
} | } | |||
catch(...) | catch(...) | |||
{ | { | |||
database.HighLevelClear(); | database.HighLevelClear(); | |||
throw; | throw; | |||
} | } | |||
} | } | |||
// catch(const CInBufferException &e) { return e.ErrorCode; } | // catch(const CInBufferException &e) { return e.ErrorCode; } | |||
catch(CEnexpectedEndException &) { UnexpectedEnd = true; } | catch(CEnexpectedEndException &) { UnexpectedEnd = true; } | |||
End of changes. 6 change blocks. | ||||
9 lines changed or deleted | 26 lines changed or added |