summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-12-06 22:21:18 (GMT)
committerGeorg Brandl <georg@python.org>2006-12-06 22:21:18 (GMT)
commit87fa5594790fda836c8a59708de60513430c0328 (patch)
treef8f2676661834478a3ef49f76c28f71084b01d34 /Lib/tarfile.py
parent0a286d0b538478e490e6f85ae3339e4bd6846953 (diff)
downloadcpython-87fa5594790fda836c8a59708de60513430c0328.zip
cpython-87fa5594790fda836c8a59708de60513430c0328.tar.gz
cpython-87fa5594790fda836c8a59708de60513430c0328.tar.bz2
Patch #1610437: fix a tarfile bug with long filename headers.
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r--Lib/tarfile.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index b5f9f30..1b8f140 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -857,7 +857,11 @@ class TarInfo(object):
if self.name.endswith("/"):
type = DIRTYPE
- name = normpath(self.name)
+ if type in (GNUTYPE_LONGNAME, GNUTYPE_LONGLINK):
+ # Prevent "././@LongLink" from being normalized.
+ name = self.name
+ else:
+ name = normpath(self.name)
if type == DIRTYPE:
# directories should end with '/'
@@ -913,7 +917,7 @@ class TarInfo(object):
]
buf += struct.pack("%ds" % BLOCKSIZE, "".join(parts))
- chksum = calc_chksums(buf)[0]
+ chksum = calc_chksums(buf[-BLOCKSIZE:])[0]
buf = buf[:-364] + "%06o\0" % chksum + buf[-357:]
self.buf = buf
return buf