diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-22 13:54:48 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-22 13:54:48 (GMT) |
commit | fc6e8aabf58d748369e0d3b08495ac35a67d2870 (patch) | |
tree | de4611799f11cdffa3b38ffb22f36a6dbb887ecf /Lib/gzip.py | |
parent | f186911e247b287d555852ce73afb721f8eb79b9 (diff) | |
download | cpython-fc6e8aabf58d748369e0d3b08495ac35a67d2870.zip cpython-fc6e8aabf58d748369e0d3b08495ac35a67d2870.tar.gz cpython-fc6e8aabf58d748369e0d3b08495ac35a67d2870.tar.bz2 |
#15546: Fix GzipFile.peek()'s handling of pathological input data.
This is a backport of changeset 8c07ff7f882f.
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r-- | Lib/gzip.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py index 403040b..6aacc9a 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -367,8 +367,10 @@ class GzipFile(io.BufferedIOBase): 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 |