From 67543f8cede1b9429d8d938882551ea8dfc103a4 Mon Sep 17 00:00:00 2001 From: "antoine.pitrou" Date: Sun, 17 Aug 2008 13:06:29 +0000 Subject: [PATCH] fix ZipFile.testzip() to work with very large embedded files git-svn-id: http://svn.python.org/projects/python/trunk@65761 6015fed2-1504-0410-9fe1-9d1591cc4771 --- Lib/zipfile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 609dea3f27..ac17177e9c 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 -- 2.11.4.GIT