diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-01-17 22:43:50 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-01-17 22:43:50 (GMT) |
commit | 2407ac9a4b79eeb7dff10255cd970455ef69b923 (patch) | |
tree | 35d6e5e268ccdd81b7e736aca711ffd69189da9a | |
parent | 5e5fbb612d8109078c2777e1759277f9144616d0 (diff) | |
download | cpython-2407ac9a4b79eeb7dff10255cd970455ef69b923.zip cpython-2407ac9a4b79eeb7dff10255cd970455ef69b923.tar.gz cpython-2407ac9a4b79eeb7dff10255cd970455ef69b923.tar.bz2 |
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".
-rw-r--r-- | Lib/zipfile.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index fedcb79..eae9d1f 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -208,13 +208,9 @@ def _EndRecData(fpin): # Append a blank comment and record start offset endrec.append("") 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" @@ -235,11 +231,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 |