diff options
author | Georg Brandl <georg@python.org> | 2006-12-06 22:21:23 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-12-06 22:21:23 +0000 |
commit | 25f58f6b5acb98b58e45714384f1549b61212bb1 (patch) | |
tree | fc81265846aa7a7d31bcc37b9241104f2a427846 /Lib/tarfile.py | |
parent | 19d12d4cea1c235b040474a2178c34e090a3756b (diff) | |
download | cpython-git-25f58f6b5acb98b58e45714384f1549b61212bb1.tar.gz |
Patch #1610437: fix a tarfile bug with long filename headers.
(backport from rev. 52938)
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r-- | Lib/tarfile.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index b5f9f30346..1b8f1408a7 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 |