From: Ruben Vorderman Date: Fri, 19 Nov 2021 18:07:05 +0000 (+0100) Subject: bpo-45507: EOFErrors should be thrown for truncated gzip members (GH-29029) X-Git-Tag: v3.11.0a3~208 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0ff3d95b9875805ac03aeffc37ae4458ce3b8ac0;p=thirdparty%2FPython%2Fcpython.git bpo-45507: EOFErrors should be thrown for truncated gzip members (GH-29029) --- diff --git a/Lib/gzip.py b/Lib/gzip.py index ac1781042b26..6773ea3eef09 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("