[Python-checkins] python/dist/src/Lib gzip.py,1.44,1.45
akuchling@users.sourceforge.net
akuchling at users.sourceforge.net
Thu Jun 9 16:19:35 CEST 2005
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30527
Modified Files:
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.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- gzip.py 28 Mar 2005 01:08:02 -0000 1.44
+++ gzip.py 9 Jun 2005 14:19:32 -0000 1.45
@@ -55,6 +55,7 @@
"""
myfileobj = None
+ max_read_chunk = 10 * 1024 * 1024 # 10Mb
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