diff options
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r-- | Lib/zipfile.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index e4bc019d1b..9e96e934ec 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -813,9 +813,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 |