diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2005-06-09 14:22:07 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2005-06-09 14:22:07 (GMT) |
commit | 216eed577777950422009b70e4440b3564648966 (patch) | |
tree | 21c52a1bd89290d30a63822c43ac0293edd5dd7e /Lib | |
parent | 475661e689b60143717a802dff07f4e8ef88a427 (diff) | |
download | cpython-216eed577777950422009b70e4440b3564648966.zip cpython-216eed577777950422009b70e4440b3564648966.tar.gz cpython-216eed577777950422009b70e4440b3564648966.tar.bz2 |
[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
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/gzip.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py index 5f638c4..cec8c0e 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -55,6 +55,7 @@ class GzipFile: """ myfileobj = None + max_read_chunk = 10 * 1024 * 1024 def __init__(self, filename=None, mode=None, compresslevel=9, fileobj=None): @@ -215,14 +216,14 @@ class GzipFile: 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 |