summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2008-08-17 13:06:29 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2008-08-17 13:06:29 (GMT)
commitc53427087e6fcf6680c83f7ede85ce02510c89a0 (patch)
tree147af00d67e9ef5343cdc017f3c58dc757a2dc6e /Lib
parent7f30a684c6bf8b381c74206228a3f1c2fae75d90 (diff)
downloadcpython-c53427087e6fcf6680c83f7ede85ce02510c89a0.zip
cpython-c53427087e6fcf6680c83f7ede85ce02510c89a0.tar.gz
cpython-c53427087e6fcf6680c83f7ede85ce02510c89a0.tar.bz2
fix ZipFile.testzip() to work with very large embedded files
Diffstat (limited to 'Lib')
-rw-r--r--Lib/zipfile.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 609dea3..ac17177 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -807,9 +807,14 @@ class ZipFile:
def testzip(self):
"""Read all the files and check the CRC."""
+ chunk_size = 2 ** 20
for zinfo in self.filelist:
try:
- self.read(zinfo.filename) # Check CRC-32
+ # Read by chunks, to avoid an OverflowError or a
+ # MemoryError with very large embedded files.
+ f = self.open(zinfo.filename, "r")
+ while f.read(chunk_size): # Check CRC-32
+ pass
except BadZipfile:
return zinfo.filename