bpo-45507: EOFErrors should be thrown for truncated gzip members (GH-29029)

This commit is contained in:
Ruben Vorderman 2021-11-19 19:07:05 +01:00 committed by GitHub
parent 7e44dc0ba7
commit 0ff3d95b98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View file

@ -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).