]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 68700 via svnmerge from
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Sun, 18 Jan 2009 20:34:58 +0000 (20:34 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Sun, 18 Jan 2009 20:34:58 +0000 (20:34 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r68700 | amaury.forgeotdarc | 2009-01-18 01:29:02 +0100 (Sun, 18 Jan 2009) | 10 lines

  Merged revisions 68678 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r68678 | amaury.forgeotdarc | 2009-01-17 23:43:50 +0100 (Sat, 17 Jan 2009) | 3 lines

    follow-up of #3997: since 0xFFFF numbers are not enough to indicate a zip64 format,
    always try to read the "zip64 end of directory structure".
  ........
................

Lib/zipfile.py

index 7308ce356e4b71feb2a58ed3d28c584d4492539f..93543b4b06e77eda6ee8a38c98820f03ff207b38 100644 (file)
@@ -198,13 +198,9 @@ def _EndRecData(fpin):
         # Append a blank comment and record start offset
         endrec.append(b"")
         endrec.append(filesize - sizeEndCentDir)
-        if endrec[_ECD_OFFSET] == 0xffffffff:
-            # the value for the "offset of the start of the central directory"
-            # indicates that there is a "Zip64 end of central directory"
-            # structure present, so go look for it
-            return _EndRecData64(fpin, -sizeEndCentDir, endrec)
 
-        return endrec
+        # Try to read the "Zip64 end of central directory" structure
+        return _EndRecData64(fpin, -sizeEndCentDir, endrec)
 
     # Either this is not a ZIP file, or it is a ZIP file with an archive
     # comment.  Search the end of the file for the "end of central directory"
@@ -225,11 +221,10 @@ def _EndRecData(fpin):
             # Append the archive comment and start offset
             endrec.append(comment)
             endrec.append(maxCommentStart + start)
-            if endrec[_ECD_OFFSET] == 0xffffffff:
-                # There is apparently a "Zip64 end of central directory"
-                # structure present, so go look for it
-                return _EndRecData64(fpin, start - filesize, endrec)
-            return endrec
+
+            # Try to read the "Zip64 end of central directory" structure
+            return _EndRecData64(fpin, maxCommentStart + start - filesize,
+                                 endrec)
 
     # Unable to find a valid end of central directory structure
     return