aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/Archive/ExtHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Archive/ExtHandler.cpp')
-rw-r--r--CPP/7zip/Archive/ExtHandler.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/CPP/7zip/Archive/ExtHandler.cpp b/CPP/7zip/Archive/ExtHandler.cpp
index 5af2a92..d379373 100644
--- a/CPP/7zip/Archive/ExtHandler.cpp
+++ b/CPP/7zip/Archive/ExtHandler.cpp
@@ -628,6 +628,8 @@ struct CNode
628 UInt32 Gid; // fixed 21.02 628 UInt32 Gid; // fixed 21.02
629 // UInt16 Checksum; 629 // UInt16 Checksum;
630 630
631 UInt32 NumLinksCalced;
632
631 UInt64 FileSize; 633 UInt64 FileSize;
632 CExtTime MTime; 634 CExtTime MTime;
633 CExtTime ATime; 635 CExtTime ATime;
@@ -639,17 +641,16 @@ struct CNode
639 UInt32 NumLinks; 641 UInt32 NumLinks;
640 UInt32 Flags; 642 UInt32 Flags;
641 643
642 UInt32 NumLinksCalced;
643
644 Byte Block[kNodeBlockFieldSize]; 644 Byte Block[kNodeBlockFieldSize];
645 645
646 CNode(): 646 void Construct()
647 ParentNode(-1), 647 {
648 ItemIndex(-1), 648 ParentNode = -1;
649 SymLinkIndex(-1), 649 ItemIndex = -1;
650 DirIndex(-1), 650 SymLinkIndex = -1;
651 NumLinksCalced(0) 651 DirIndex = -1;
652 {} 652 NumLinksCalced = 0;
653 }
653 654
654 bool IsFlags_HUGE() const { return (Flags & k_NodeFlags_HUGE) != 0; } 655 bool IsFlags_HUGE() const { return (Flags & k_NodeFlags_HUGE) != 0; }
655 bool IsFlags_EXTENTS() const { return (Flags & k_NodeFlags_EXTENTS) != 0; } 656 bool IsFlags_EXTENTS() const { return (Flags & k_NodeFlags_EXTENTS) != 0; }
@@ -1172,21 +1173,19 @@ HRESULT CHandler::Open2(IInStream *inStream)
1172 { 1173 {
1173 // ---------- Read groups ---------- 1174 // ---------- Read groups ----------
1174 1175
1175 CByteBuffer gdBuf;
1176 const size_t gdBufSize = (size_t)numGroups << gdBits; 1176 const size_t gdBufSize = (size_t)numGroups << gdBits;
1177 if ((gdBufSize >> gdBits) != numGroups) 1177 if ((gdBufSize >> gdBits) != numGroups)
1178 return S_FALSE; 1178 return S_FALSE;
1179 CByteBuffer gdBuf;
1179 gdBuf.Alloc(gdBufSize); 1180 gdBuf.Alloc(gdBufSize);
1180 RINOK(SeekAndRead(inStream, (_h.BlockBits <= 10 ? 2 : 1), gdBuf, gdBufSize)) 1181 RINOK(SeekAndRead(inStream, (_h.BlockBits <= 10 ? 2 : 1), gdBuf, gdBufSize))
1181 1182
1182 for (unsigned i = 0; i < numGroups; i++) 1183 const unsigned gd_Size = (unsigned)1 << gdBits;
1184 const Byte *p = gdBuf;
1185 for (unsigned i = 0; i < numGroups; i++, p += gd_Size)
1183 { 1186 {
1184 CGroupDescriptor gd; 1187 CGroupDescriptor gd;
1185
1186 const Byte *p = gdBuf + ((size_t)i << gdBits);
1187 const unsigned gd_Size = (unsigned)1 << gdBits;
1188 gd.Parse(p, gd_Size); 1188 gd.Parse(p, gd_Size);
1189
1190 if (_h.UseMetadataChecksum()) 1189 if (_h.UseMetadataChecksum())
1191 { 1190 {
1192 // use CRC32c 1191 // use CRC32c
@@ -1228,7 +1227,10 @@ HRESULT CHandler::Open2(IInStream *inStream)
1228 if (numNodes > (1 << 24)) 1227 if (numNodes > (1 << 24))
1229 return S_FALSE; 1228 return S_FALSE;
1230 } 1229 }
1231 1230
1231 const size_t blockSize = (size_t)1 << _h.BlockBits;
1232 if (numNodes > blockSize * 8)
1233 return S_FALSE;
1232 const UInt32 numReserveInodes = _h.NumInodes - _h.NumFreeInodes + 1; 1234 const UInt32 numReserveInodes = _h.NumInodes - _h.NumFreeInodes + 1;
1233 // numReserveInodes = _h.NumInodes + 1; 1235 // numReserveInodes = _h.NumInodes + 1;
1234 if (numReserveInodes != 0) 1236 if (numReserveInodes != 0)
@@ -1241,7 +1243,6 @@ HRESULT CHandler::Open2(IInStream *inStream)
1241 nodesData.Alloc(nodesDataSize); 1243 nodesData.Alloc(nodesDataSize);
1242 1244
1243 CByteBuffer nodesMap; 1245 CByteBuffer nodesMap;
1244 const size_t blockSize = (size_t)1 << _h.BlockBits;
1245 nodesMap.Alloc(blockSize); 1246 nodesMap.Alloc(blockSize);
1246 1247
1247 unsigned globalNodeIndex = 0; 1248 unsigned globalNodeIndex = 0;
@@ -1282,6 +1283,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
1282 } 1283 }
1283 1284
1284 CNode node; 1285 CNode node;
1286 node.Construct();
1285 1287
1286 PRF(printf("\nnode = %5d ", (unsigned)n)); 1288 PRF(printf("\nnode = %5d ", (unsigned)n));
1287 1289