mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
Patch #1262036: Prevent TarFiles from being added to themselves under
certain conditions. Will backport to 2.5.
This commit is contained in:
parent
6baa502769
commit
a4b2381b20
3 changed files with 23 additions and 27 deletions
|
@ -290,6 +290,20 @@ class WriteTest(BaseTest):
|
|||
else:
|
||||
self.dst.addfile(tarinfo, f)
|
||||
|
||||
def test_add_self(self):
|
||||
dstname = os.path.abspath(self.dstname)
|
||||
|
||||
self.assertEqual(self.dst.name, dstname, "archive name must be absolute")
|
||||
|
||||
self.dst.add(dstname)
|
||||
self.assertEqual(self.dst.getnames(), [], "added the archive to itself")
|
||||
|
||||
cwd = os.getcwd()
|
||||
os.chdir(dirname())
|
||||
self.dst.add(dstname)
|
||||
os.chdir(cwd)
|
||||
self.assertEqual(self.dst.getnames(), [], "added the archive to itself")
|
||||
|
||||
|
||||
class Write100Test(BaseTest):
|
||||
# The name field in a tar header stores strings of at most 100 chars.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue