diff options
author | Ruben Vorderman <r.h.p.vorderman@lumc.nl> | 2021-11-19 18:07:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 18:07:05 (GMT) |
commit | 0ff3d95b9875805ac03aeffc37ae4458ce3b8ac0 (patch) | |
tree | 6f82877c128a0bab19926e8fe4b3a9d7eb3716b2 /Lib/test/test_gzip.py | |
parent | 7e44dc0ba768451f287a541cd1c85f7d87a41561 (diff) | |
download | cpython-0ff3d95b9875805ac03aeffc37ae4458ce3b8ac0.zip cpython-0ff3d95b9875805ac03aeffc37ae4458ce3b8ac0.tar.gz cpython-0ff3d95b9875805ac03aeffc37ae4458ce3b8ac0.tar.bz2 |
bpo-45507: EOFErrors should be thrown for truncated gzip members (GH-29029)
Diffstat (limited to 'Lib/test/test_gzip.py')
-rw-r--r-- | Lib/test/test_gzip.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index f86e767..aa66d2f 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -562,6 +562,14 @@ class TestGzip(BaseTest): datac = gzip.compress(data) self.assertEqual(gzip.decompress(datac), data) + def test_decompress_truncated_trailer(self): + compressed_data = gzip.compress(data1) + self.assertRaises(EOFError, gzip.decompress, compressed_data[:-4]) + + def test_decompress_missing_trailer(self): + compressed_data = gzip.compress(data1) + self.assertRaises(EOFError, gzip.decompress, compressed_data[:-8]) + def test_read_truncated(self): data = data1*50 # Drop the CRC (4 bytes) and file size (4 bytes). |