[3.14] gh-132983: Don't allow trailer data in ZstdFile (GH-133736) (#133799)

gh-132983: Don't allow trailer data in ZstdFile (GH-133736)
(cherry picked from commit 50b5370664)

Co-authored-by: Rogdham <3994389+Rogdham@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2025-05-10 04:58:43 +02:00 committed by GitHub
parent f6a4604017
commit 99ca086f91
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