UdfIn.cpp (p7zip_15.14.1_src_all) | : | UdfIn.cpp (p7zip_16.02_src_all) | ||
---|---|---|---|---|
skipping to change at line 388 | skipping to change at line 388 | |||
} | } | |||
HRESULT CInArchive::ReadFileItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed) | HRESULT CInArchive::ReadFileItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed) | |||
{ | { | |||
if (Files.Size() % 100 == 0) | if (Files.Size() % 100 == 0) | |||
RINOK(_progress->SetCompleted(Files.Size(), _processedProgressBytes)); | RINOK(_progress->SetCompleted(Files.Size(), _processedProgressBytes)); | |||
if (numRecurseAllowed-- == 0) | if (numRecurseAllowed-- == 0) | |||
return S_FALSE; | return S_FALSE; | |||
CFile &file = Files.Back(); | CFile &file = Files.Back(); | |||
const CLogVol &vol = LogVols[volIndex]; | const CLogVol &vol = LogVols[volIndex]; | |||
CPartition &partition = Partitions[vol.PartitionMaps[lad.Location.PartitionRef | unsigned partitionRef = lad.Location.PartitionRef; | |||
].PartitionIndex]; | if (partitionRef >= vol.PartitionMaps.Size()) | |||
return S_FALSE; | ||||
CPartition &partition = Partitions[vol.PartitionMaps[partitionRef].PartitionIn | ||||
dex]; | ||||
UInt32 key = lad.Location.Pos; | UInt32 key = lad.Location.Pos; | |||
UInt32 value; | UInt32 value; | |||
const UInt32 kRecursedErrorValue = (UInt32)(Int32)-1; | const UInt32 kRecursedErrorValue = (UInt32)(Int32)-1; | |||
if (partition.Map.Find(key, value)) | if (partition.Map.Find(key, value)) | |||
{ | { | |||
if (value == kRecursedErrorValue) | if (value == kRecursedErrorValue) | |||
return S_FALSE; | return S_FALSE; | |||
file.ItemIndex = value; | file.ItemIndex = value; | |||
} | } | |||
skipping to change at line 424 | skipping to change at line 427 | |||
if (Items.Size() > kNumItemsMax) | if (Items.Size() > kNumItemsMax) | |||
return S_FALSE; | return S_FALSE; | |||
Items.Add(CItem()); | Items.Add(CItem()); | |||
CItem &item = Items.Back(); | CItem &item = Items.Back(); | |||
const CLogVol &vol = LogVols[volIndex]; | const CLogVol &vol = LogVols[volIndex]; | |||
if (lad.GetLen() != vol.BlockSize) | if (lad.GetLen() != vol.BlockSize) | |||
return S_FALSE; | return S_FALSE; | |||
size_t size = lad.GetLen(); | const size_t size = lad.GetLen(); | |||
CByteBuffer buf(size); | CByteBuffer buf(size); | |||
RINOK(Read(volIndex, lad, buf)); | RINOK(Read(volIndex, lad, buf)); | |||
CTag tag; | CTag tag; | |||
const Byte *p = buf; | const Byte *p = buf; | |||
RINOK(tag.Parse(p, size)); | RINOK(tag.Parse(p, size)); | |||
if (size < 176) | if (size < 176) | |||
return S_FALSE; | return S_FALSE; | |||
if (tag.Id != DESC_TYPE_File) | if (tag.Id != DESC_TYPE_File) | |||
return S_FALSE; | return S_FALSE; | |||
skipping to change at line 514 | skipping to change at line 517 | |||
i += 16; | i += 16; | |||
} | } | |||
item.Extents.Add(e); | item.Extents.Add(e); | |||
} | } | |||
} | } | |||
if (item.IcbTag.IsDir()) | if (item.IcbTag.IsDir()) | |||
{ | { | |||
if (!item.CheckChunkSizes() || !CheckItemExtents(volIndex, item)) | if (!item.CheckChunkSizes() || !CheckItemExtents(volIndex, item)) | |||
return S_FALSE; | return S_FALSE; | |||
CByteBuffer buf; | CByteBuffer buf2; | |||
RINOK(ReadFromFile(volIndex, item, buf)); | RINOK(ReadFromFile(volIndex, item, buf2)); | |||
item.Size = 0; | item.Size = 0; | |||
item.Extents.ClearAndFree(); | item.Extents.ClearAndFree(); | |||
item.InlineData.Free(); | item.InlineData.Free(); | |||
const Byte *p = buf; | const Byte *p2 = buf2; | |||
size = buf.Size(); | const size_t size2 = buf2.Size(); | |||
size_t processedTotal = 0; | size_t processedTotal = 0; | |||
for (; processedTotal < size;) | for (; processedTotal < size2;) | |||
{ | { | |||
size_t processedCur; | size_t processedCur; | |||
CFileId fileId; | CFileId fileId; | |||
RINOK(fileId.Parse(p + processedTotal, size - processedTotal, processedCur )); | RINOK(fileId.Parse(p2 + processedTotal, size2 - processedTotal, processedC ur)); | |||
if (!fileId.IsItLinkParent()) | if (!fileId.IsItLinkParent()) | |||
{ | { | |||
CFile file; | CFile file; | |||
// file.FileVersion = fileId.FileVersion; | // file.FileVersion = fileId.FileVersion; | |||
// file.FileCharacteristics = fileId.FileCharacteristics; | // file.FileCharacteristics = fileId.FileCharacteristics; | |||
// file.ImplUse = fileId.ImplUse; | // file.ImplUse = fileId.ImplUse; | |||
file.Id = fileId.Id; | file.Id = fileId.Id; | |||
_fileNameLengthTotal += file.Id.Data.Size(); | _fileNameLengthTotal += file.Id.Data.Size(); | |||
if (_fileNameLengthTotal > kFileNameLengthTotalMax) | if (_fileNameLengthTotal > kFileNameLengthTotalMax) | |||
skipping to change at line 595 | skipping to change at line 598 | |||
} | } | |||
API_FUNC_IsArc IsArc_Udf(const Byte *p, size_t size) | API_FUNC_IsArc IsArc_Udf(const Byte *p, size_t size) | |||
{ | { | |||
UInt32 res = k_IsArc_Res_NO; | UInt32 res = k_IsArc_Res_NO; | |||
unsigned SecLogSize; | unsigned SecLogSize; | |||
for (SecLogSize = 11;; SecLogSize -= 3) | for (SecLogSize = 11;; SecLogSize -= 3) | |||
{ | { | |||
if (SecLogSize < 8) | if (SecLogSize < 8) | |||
return res; | return res; | |||
UInt32 offset = (UInt32)256 << SecLogSize; | const UInt32 offset = (UInt32)256 << SecLogSize; | |||
size_t bufSize = (UInt32)1 << SecLogSize; | const UInt32 bufSize = (UInt32)1 << SecLogSize; | |||
if (offset + bufSize > size) | if (offset + bufSize > size) | |||
res = k_IsArc_Res_NEED_MORE; | res = k_IsArc_Res_NEED_MORE; | |||
else | else | |||
{ | { | |||
CTag tag; | CTag tag; | |||
if (tag.Parse(p + offset, bufSize) == S_OK) | if (tag.Parse(p + offset, bufSize) == S_OK) | |||
if (tag.Id == DESC_TYPE_AnchorVolPtr) | if (tag.Id == DESC_TYPE_AnchorVolPtr) | |||
return k_IsArc_Res_YES; | return k_IsArc_Res_YES; | |||
} | } | |||
} | } | |||
skipping to change at line 655 | skipping to change at line 658 | |||
Byte buf[kBufSize]; | Byte buf[kBufSize]; | |||
for (SecLogSize = 11;; SecLogSize -= 3) | for (SecLogSize = 11;; SecLogSize -= 3) | |||
{ | { | |||
if (SecLogSize < 8) | if (SecLogSize < 8) | |||
return S_FALSE; | return S_FALSE; | |||
UInt32 offset = (UInt32)256 << SecLogSize; | UInt32 offset = (UInt32)256 << SecLogSize; | |||
if (offset >= fileSize) | if (offset >= fileSize) | |||
continue; | continue; | |||
RINOK(_stream->Seek(offset, STREAM_SEEK_SET, NULL)); | RINOK(_stream->Seek(offset, STREAM_SEEK_SET, NULL)); | |||
size_t bufSize = (UInt32)1 << SecLogSize; | const size_t bufSize = (size_t)1 << SecLogSize; | |||
size_t readSize = bufSize; | size_t readSize = bufSize; | |||
RINOK(ReadStream(_stream, buf, &readSize)); | RINOK(ReadStream(_stream, buf, &readSize)); | |||
if (readSize == bufSize) | if (readSize == bufSize) | |||
{ | { | |||
CTag tag; | CTag tag; | |||
if (tag.Parse(buf, readSize) == S_OK) | if (tag.Parse(buf, readSize) == S_OK) | |||
if (tag.Id == DESC_TYPE_AnchorVolPtr) | if (tag.Id == DESC_TYPE_AnchorVolPtr) | |||
break; | break; | |||
} | } | |||
} | } | |||
skipping to change at line 681 | skipping to change at line 684 | |||
extentVDS.Parse(buf + 16); | extentVDS.Parse(buf + 16); | |||
{ | { | |||
CExtent extentVDS2; | CExtent extentVDS2; | |||
extentVDS2.Parse(buf + 24); | extentVDS2.Parse(buf + 24); | |||
UpdatePhySize(((UInt64)extentVDS.Pos << SecLogSize) + extentVDS.Len); | UpdatePhySize(((UInt64)extentVDS.Pos << SecLogSize) + extentVDS.Len); | |||
UpdatePhySize(((UInt64)extentVDS2.Pos << SecLogSize) + extentVDS2.Len); | UpdatePhySize(((UInt64)extentVDS2.Pos << SecLogSize) + extentVDS2.Len); | |||
} | } | |||
for (UInt32 location = 0; ; location++) | for (UInt32 location = 0; ; location++) | |||
{ | { | |||
size_t bufSize = (UInt32)1 << SecLogSize; | const size_t bufSize = (size_t)1 << SecLogSize; | |||
size_t pos = 0; | ||||
if (((UInt64)(location + 1) << SecLogSize) > extentVDS.Len) | if (((UInt64)(location + 1) << SecLogSize) > extentVDS.Len) | |||
return S_FALSE; | return S_FALSE; | |||
UInt64 offs = (UInt64)(extentVDS.Pos + location) << SecLogSize; | UInt64 offs = (UInt64)(extentVDS.Pos + location) << SecLogSize; | |||
RINOK(_stream->Seek(offs, STREAM_SEEK_SET, NULL)); | RINOK(_stream->Seek(offs, STREAM_SEEK_SET, NULL)); | |||
HRESULT res = ReadStream_FALSE(_stream, buf, bufSize); | HRESULT res = ReadStream_FALSE(_stream, buf, bufSize); | |||
if (res == S_FALSE && offs + bufSize > FileSize) | if (res == S_FALSE && offs + bufSize > FileSize) | |||
UnexpectedEnd = true; | UnexpectedEnd = true; | |||
RINOK(res); | RINOK(res); | |||
CTag tag; | CTag tag; | |||
RINOK(tag.Parse(buf + pos, bufSize - pos)); | { | |||
const size_t pos = 0; | ||||
RINOK(tag.Parse(buf + pos, bufSize - pos)); | ||||
} | ||||
if (tag.Id == DESC_TYPE_Terminating) | if (tag.Id == DESC_TYPE_Terminating) | |||
break; | break; | |||
if (tag.Id == DESC_TYPE_Partition) | if (tag.Id == DESC_TYPE_Partition) | |||
{ | { | |||
// Partition Descriptor | // Partition Descriptor | |||
// ECMA 167 3/10.5 | // ECMA 167 3/10.5 | |||
// UDF / 2.2.14 | // UDF / 2.2.14 | |||
if (Partitions.Size() >= kNumPartitionsMax) | if (Partitions.Size() >= kNumPartitionsMax) | |||
skipping to change at line 856 | skipping to change at line 861 | |||
CLogVol &vol = LogVols[volIndex]; | CLogVol &vol = LogVols[volIndex]; | |||
PRF(printf("\nLogVol %2d", volIndex)); | PRF(printf("\nLogVol %2d", volIndex)); | |||
CLongAllocDesc nextExtent = vol.FileSetLocation; | CLongAllocDesc nextExtent = vol.FileSetLocation; | |||
// while (nextExtent.ExtentLen != 0) | // while (nextExtent.ExtentLen != 0) | |||
// for (int i = 0; i < 1; i++) | // for (int i = 0; i < 1; i++) | |||
{ | { | |||
if (nextExtent.GetLen() < 512) | if (nextExtent.GetLen() < 512) | |||
return S_FALSE; | return S_FALSE; | |||
CByteBuffer buf(nextExtent.GetLen()); | CByteBuffer buf2(nextExtent.GetLen()); | |||
RINOK(Read(volIndex, nextExtent, buf)); | RINOK(Read(volIndex, nextExtent, buf2)); | |||
const Byte *p = buf; | const Byte *p = buf2; | |||
size_t size = nextExtent.GetLen(); | size_t size = nextExtent.GetLen(); | |||
CTag tag; | CTag tag; | |||
RINOK(tag.Parse(p, size)); | RINOK(tag.Parse(p, size)); | |||
if (tag.Id == DESC_TYPE_ExtendedFile) | if (tag.Id == DESC_TYPE_ExtendedFile) | |||
{ | { | |||
// ECMA 4 / 14.17 | // ECMA 4 / 14.17 | |||
// 2.60 ?? | // 2.60 ?? | |||
return S_FALSE; | return S_FALSE; | |||
End of changes. 11 change blocks. | ||||
18 lines changed or deleted | 23 lines changed or added |