diff options
author | Ruben Vorderman <r.h.p.vorderman@lumc.nl> | 2021-11-19 19:07:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 19:07:05 +0100 |
commit | 0ff3d95b9875805ac03aeffc37ae4458ce3b8ac0 (patch) | |
tree | 6f82877c128a0bab19926e8fe4b3a9d7eb3716b2 /Lib/gzip.py | |
parent | 7e44dc0ba768451f287a541cd1c85f7d87a41561 (diff) | |
download | cpython-git-0ff3d95b9875805ac03aeffc37ae4458ce3b8ac0.tar.gz |
bpo-45507: EOFErrors should be thrown for truncated gzip members (GH-29029)
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r-- | Lib/gzip.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py index ac1781042b..6773ea3eef 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -603,6 +603,9 @@ def decompress(data): do = zlib.decompressobj(wbits=-zlib.MAX_WBITS) # Read all the data except the header decompressed = do.decompress(data[fp.tell():]) + if not do.eof or len(do.unused_data) < 8: + raise EOFError("Compressed file ended before the end-of-stream " + "marker was reached") crc, length = struct.unpack("<II", do.unused_data[:8]) if crc != zlib.crc32(decompressed): raise BadGzipFile("CRC check failed") |