summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-10-24 16:54:16 (GMT)
committerGeorg Brandl <georg@python.org>2006-10-24 16:54:16 (GMT)
commita32e0a099bb85ab355bdebd7c494060c1cfc0171 (patch)
treee6a5abc9c54f0d653e974578646e808b065fc0b2 /Lib/test
parente97c75966021bbcb2ef219e6602aea80c7b06ed9 (diff)
downloadcpython-a32e0a099bb85ab355bdebd7c494060c1cfc0171.zip
cpython-a32e0a099bb85ab355bdebd7c494060c1cfc0171.tar.gz
cpython-a32e0a099bb85ab355bdebd7c494060c1cfc0171.tar.bz2
Patch [ 1583506 ] tarfile.py: 100-char filenames are truncated
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_tarfile.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index ebcb8c5..ee83cbe 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -280,6 +280,32 @@ class WriteTest(BaseTest):
else:
self.dst.addfile(tarinfo, f)
+
+class Write100Test(BaseTest):
+ # The name field in a tar header stores strings of at most 100 chars.
+ # If a string is shorter than 100 chars it has to be padded with '\0',
+ # which implies that a string of exactly 100 chars is stored without
+ # a trailing '\0'.
+
+ def setUp(self):
+ self.name = "01234567890123456789012345678901234567890123456789"
+ self.name += "01234567890123456789012345678901234567890123456789"
+
+ self.tar = tarfile.open(tmpname(), "w")
+ t = tarfile.TarInfo(self.name)
+ self.tar.addfile(t)
+ self.tar.close()
+
+ self.tar = tarfile.open(tmpname())
+
+ def tearDown(self):
+ self.tar.close()
+
+ def test(self):
+ self.assertEqual(self.tar.getnames()[0], self.name,
+ "failed to store 100 char filename")
+
+
class WriteSize0Test(BaseTest):
mode = 'w'
@@ -623,6 +649,7 @@ def test_main():
ReadAsteriskTest,
ReadStreamAsteriskTest,
WriteTest,
+ Write100Test,
WriteSize0Test,
WriteStreamTest,
WriteGNULongTest,