diff --git a/Lib/gzip.py b/Lib/gzip.py index 0dddb51553fabd..27211eef0d63a2 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -607,6 +607,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("