提交 775477aa 编写于 作者: J Johannes Schindelin 提交者: Shawn O. Pearce

Teach import-tars about GNU tar's @LongLink extension.

This extension allows GNU tar to process file names in excess of the 100
characters defined by the original tar standard. It does this by faking a
file, named '././@LongLink' containing the true file name, and then adding
the file with a truncated name. The idea is that tar without this
extension will write out a file with the long file name, and write the
contents into a file with truncated name.

Unfortunately, GNU tar does a lousy job at times. When truncating results
in a _directory_ name, it will happily use _that_ as a truncated name for
the file.

An example where this actually happens is gcc-4.1.2, where the full path
of the file WeThrowThisExceptionHelper.java truncates _exactly_ before the
basename. So, we have to support that ad-hoc extension.

This bug was noticed by Chris Riddoch on IRC.
Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
上级 b5cc62f7
......@@ -52,6 +52,25 @@
Z8 Z1 Z100 Z6
Z2 Z32 Z32 Z8 Z8 Z*', $_;
last unless $name;
if ($name eq '././@LongLink') {
# GNU tar extension
if (read(I, $_, 512) != 512) {
die ('Short archive');
}
$name = unpack 'Z257', $_;
next unless $name;
my $dummy;
if (read(I, $_, 512) != 512) {
die ('Short archive');
}
($dummy, $mode, $uid, $gid, $size, $mtime,
$chksum, $typeflag, $linkname, $magic,
$version, $uname, $gname, $devmajor, $devminor,
$prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12
Z8 Z1 Z100 Z6
Z2 Z32 Z32 Z8 Z8 Z*', $_;
}
next if $name =~ m{/\z};
$mode = oct $mode;
$size = oct $size;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册