Kaydet (Commit) 2b4b5a54 authored tarafından Jack Jansen's avatar Jack Jansen

Fix by Lars Gustaebel for bug 721871: don't get upset if the prefix

field contains garbage after the first NUL character.
üst 70995830
...@@ -671,18 +671,13 @@ class TarInfo(object): ...@@ -671,18 +671,13 @@ class TarInfo(object):
tarinfo.devminor = int(buf[337:345], 8) tarinfo.devminor = int(buf[337:345], 8)
except ValueError: except ValueError:
tarinfo.devmajor = tarinfo.devmajor = 0 tarinfo.devmajor = tarinfo.devmajor = 0
tarinfo.prefix = buf[345:500]
# The prefix field is used for filenames > 100 in # The prefix field is used for filenames > 100 in
# the POSIX standard. # the POSIX standard.
# name = prefix + "/" + name # name = prefix + '/' + name
prefix = buf[345:500] if tarinfo.type != GNUTYPE_SPARSE:
while prefix and prefix[-1] == NUL: tarinfo.name = normpath(os.path.join(nts(tarinfo.prefix), tarinfo.name))
prefix = prefix[:-1]
if len(prefix.split(NUL)) == 1:
tarinfo.prefix = prefix
tarinfo.name = normpath(os.path.join(tarinfo.prefix, tarinfo.name))
else:
tarinfo.prefix = buf[345:500]
# Directory names should have a '/' at the end. # Directory names should have a '/' at the end.
if tarinfo.isdir() and tarinfo.name[-1:] != "/": if tarinfo.isdir() and tarinfo.name[-1:] != "/":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment