[Python-checkins] python/dist/src/Lib gzip.py,1.42,1.42.4.1

akuchling@users.sourceforge.net akuchling at users.sourceforge.net
Thu Jun 9 16:22:10 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32057

Modified Files:
      Tag: release24-maint
	gzip.py 
Log Message:
[Bug #1074261, patch #1074381] Restrict the size of chunks read from the file in order to avoid overflow or huge memory consumption.  Patch by Mark Eichin

Index: gzip.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/gzip.py,v
retrieving revision 1.42
retrieving revision 1.42.4.1
diff -u -d -r1.42 -r1.42.4.1
--- gzip.py	27 Jul 2004 21:05:21 -0000	1.42
+++ gzip.py	9 Jun 2005 14:22:07 -0000	1.42.4.1
@@ -55,6 +55,7 @@
     """
 
     myfileobj = None
+    max_read_chunk = 10 * 1024 * 1024
 
     def __init__(self, filename=None, mode=None,
                  compresslevel=9, fileobj=None):
@@ -215,14 +216,14 @@
             try:
                 while True:
                     self._read(readsize)
-                    readsize = readsize * 2
+                    readsize = min(self.max_read_chunk, readsize * 2)
             except EOFError:
                 size = self.extrasize
         else:               # just get some more of it
             try:
                 while size > self.extrasize:
                     self._read(readsize)
-                    readsize = readsize * 2
+                    readsize = min(self.max_read_chunk, readsize * 2)
             except EOFError:
                 if size > self.extrasize:
                     size = self.extrasize



More information about the Python-checkins mailing list