mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-39017: Avoid infinite loop in the tarfile module (GH-21454)
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907).
This commit is contained in:
parent
bbceef6851
commit
5a8d121a1f
4 changed files with 10 additions and 0 deletions
|
@ -429,6 +429,13 @@ class CommonReadTest(ReadTest):
|
|||
with self.assertRaisesRegex(tarfile.ReadError, "unexpected end of data"):
|
||||
tar.extractfile(t).read()
|
||||
|
||||
def test_length_zero_header(self):
|
||||
# bpo-39017 (CVE-2019-20907): reading a zero-length header should fail
|
||||
# with an exception
|
||||
with self.assertRaisesRegex(tarfile.ReadError, "file could not be opened successfully"):
|
||||
with tarfile.open(support.findfile('recursion.tar')) as tar:
|
||||
pass
|
||||
|
||||
class MiscReadTestBase(CommonReadTest):
|
||||
def requires_name_attribute(self):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue