File p7zip-9.20.1-CVE-2016-1372.patch of Package p7zip.34729

Index: p7zip_9.20.1/CPP/7zip/Archive/7z/7zIn.cpp
===================================================================
--- p7zip_9.20.1.orig/CPP/7zip/Archive/7z/7zIn.cpp
+++ p7zip_9.20.1/CPP/7zip/Archive/7z/7zIn.cpp
@@ -111,6 +111,20 @@ static inline void ThrowUnsupported() {
 static inline void ThrowIncorrect()   { ThrowException(); }
 static inline void ThrowUnsupportedVersion() { ThrowException(); }
 
+UInt64 CArchiveDatabaseEx::GetFolderFullPackSize(int folderIndex) const
+{
+  CNum packStreamIndex = FolderStartPackStreamIndex[folderIndex];
+  const CFolder &folder = Folders[folderIndex];
+  UInt64 size = 0;
+  for (int i = 0; i < folder.PackStreams.Size(); i++)
+  {
+    if (PackSizes.IsEmpty())
+      ThrowIncorrect();
+    size += PackSizes[packStreamIndex + i];
+  }
+  return size;
+}
+
 /*
 class CInArchiveException
 {
@@ -173,6 +187,8 @@ void CStreamSwitch::Set(CInArchive *arch
   Byte external = archive->ReadByte();
   if (external != 0)
   {
+    if (!dataVector)
+      ThrowIncorrect();
     int dataIndex = (int)archive->ReadNum();
     if (dataIndex < 0 || dataIndex >= dataVector->Size())
       ThrowIncorrect();
@@ -1028,6 +1044,9 @@ HRESULT CInArchive::ReadHeader(
       ThrowIncorrect();
   }
 
+  if (numFiles - numEmptyStreams != unpackSizes.Size())
+    ThrowUnsupported();
+
   CNum emptyFileIndex = 0;
   CNum sizeIndex = 0;
 
Index: p7zip_9.20.1/CPP/7zip/Archive/7z/7zIn.h
===================================================================
--- p7zip_9.20.1.orig/CPP/7zip/Archive/7z/7zIn.h
+++ p7zip_9.20.1/CPP/7zip/Archive/7z/7zIn.h
@@ -71,15 +71,7 @@ struct CArchiveDatabaseEx: public CArchi
         PackStreamStartPositions[FolderStartPackStreamIndex[folderIndex] + indexInFolder];
   }
   
-  UInt64 GetFolderFullPackSize(int folderIndex) const
-  {
-    CNum packStreamIndex = FolderStartPackStreamIndex[folderIndex];
-    const CFolder &folder = Folders[folderIndex];
-    UInt64 size = 0;
-    for (int i = 0; i < folder.PackStreams.Size(); i++)
-      size += PackSizes[packStreamIndex + i];
-    return size;
-  }
+  UInt64 GetFolderFullPackSize(int folderIndex) const;
   
   UInt64 GetFolderPackStreamSize(int folderIndex, int streamIndex) const
   {
openSUSE Build Service is sponsored by