diff options
author | Lars Gustäbel <lars@gustaebel.de> | 2006-12-23 17:57:23 (GMT) |
---|---|---|
committer | Lars Gustäbel <lars@gustaebel.de> | 2006-12-23 17:57:23 (GMT) |
commit | a4b2381b20edfc8be76df63ef06c0f15959ad7a3 (patch) | |
tree | 9351a503cff6c6269fa3ee8b5e9c53f9f27aa0a4 /Lib/test/test_tarfile.py | |
parent | 6baa5027699c6238d545a9b18c70567882517eae (diff) | |
download | cpython-a4b2381b20edfc8be76df63ef06c0f15959ad7a3.zip cpython-a4b2381b20edfc8be76df63ef06c0f15959ad7a3.tar.gz cpython-a4b2381b20edfc8be76df63ef06c0f15959ad7a3.tar.bz2 |
Patch #1262036: Prevent TarFiles from being added to themselves under
certain conditions.
Will backport to 2.5.
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r-- | Lib/test/test_tarfile.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index 867eca4..a76ceb1 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -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. |