gh-132983: Don't allow trailer data in ZstdFile (#133736)

This commit is contained in:
Rogdham 2025-05-10 04:32:22 +02:00 committed by GitHub
parent c896dae029
commit 50b5370664
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

View file

@ -1682,10 +1682,10 @@ class FileTestCase(unittest.TestCase):
# Trailing data isn't a valid compressed stream
with ZstdFile(io.BytesIO(self.FRAME_42 + b'12345')) as f:
self.assertEqual(f.read(), self.DECOMPRESSED_42)
self.assertRaises(ZstdError, f.read)
with ZstdFile(io.BytesIO(SKIPPABLE_FRAME + b'12345')) as f:
self.assertEqual(f.read(), b'')
self.assertRaises(ZstdError, f.read)
def test_read_truncated(self):
# Drop stream epilogue: 4 bytes checksum