[Python-checkins] cpython (3.2): #15546: Fix GzipFile.peek()'s handling of pathological input data.
serhiy.storchaka
python-checkins at python.org
Tue Jan 22 14:59:30 CET 2013
http://hg.python.org/cpython/rev/0f25119ceee8
changeset: 81651:0f25119ceee8
branch: 3.2
parent: 81648:1ff413ba4414
user: Serhiy Storchaka <storchaka at gmail.com>
date: Tue Jan 22 15:54:48 2013 +0200
summary:
#15546: Fix GzipFile.peek()'s handling of pathological input data.
This is a backport of changeset 8c07ff7f882f.
files:
Lib/gzip.py | 6 ++++--
Misc/NEWS | 3 +++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Lib/gzip.py b/Lib/gzip.py
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -367,8 +367,10 @@
if self.fileobj is None:
return b''
try:
- # 1024 is the same buffering heuristic used in read()
- self._read(max(n, 1024))
+ # Ensure that we don't return b"" if we haven't reached EOF.
+ while self.extrasize == 0:
+ # 1024 is the same buffering heuristic used in read()
+ self._read(max(n, 1024))
except EOFError:
pass
offset = self.offset - self.extrastart
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -466,6 +466,9 @@
- Issue #15424: Add a __sizeof__ implementation for array objects.
Patch by Ludwig Hähne.
+- Issue #15546: Fix handling of pathological input data in the peek() method
+ of the GzipFile class.
+
- Issue #13052: Fix IDLE crashing when replace string in Search/Replace dialog
ended with '\'. Patch by Roger Serwy.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list