mirror of
https://github.com/python/cpython.git
synced 2026-06-28 03:41:13 +00:00
[3.15] gh-150599: Prevent bz2 decompressor reuse after errors (GH-150600)
(cherry picked from commit 5755d0f083)
Co-authored-by: Stan Ulbrych <stan@python.org>
This commit is contained in:
parent
a642d1ab38
commit
d3ca26983d
3 changed files with 33 additions and 3 deletions
|
|
@ -1032,6 +1032,21 @@ def test_failure(self):
|
|||
# Previously, a second call could crash due to internal inconsistency
|
||||
self.assertRaises(Exception, bzd.decompress, self.BAD_DATA * 30)
|
||||
|
||||
def test_decompress_after_data_error(self):
|
||||
data = bytes.fromhex(
|
||||
"425a6839314159265359000000000000007fffff000000000000000000000000"
|
||||
"00000000000000000000000000000000000000e0370000000000000000000000"
|
||||
"000000000000000000000000000000000000000000000000000083f3"
|
||||
)
|
||||
bzd = BZ2Decompressor()
|
||||
with self.assertRaisesRegex(OSError, "Invalid data stream"):
|
||||
bzd.decompress(data)
|
||||
# Previously, a second call could crash due to internal inconsistency
|
||||
self.assertFalse(bzd.needs_input)
|
||||
self.assertFalse(bzd.eof)
|
||||
with self.assertRaisesRegex(ValueError, "previous error"):
|
||||
bzd.decompress(b'\x00' * 18)
|
||||
|
||||
@support.refcount_test
|
||||
def test_refleaks_in___init__(self):
|
||||
gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue