tar: fix handling of tarballs with symlinks with size field != 0
This commit is contained in:
parent
b9bbc40f64
commit
adc772a5f2
@ -266,26 +266,31 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
case '0':
|
||||
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
if (last_char_is(file_header->name, '/')) {
|
||||
file_header->mode |= S_IFDIR;
|
||||
} else
|
||||
goto set_dir;
|
||||
}
|
||||
#endif
|
||||
file_header->mode |= S_IFREG;
|
||||
break;
|
||||
case '2':
|
||||
file_header->mode |= S_IFLNK;
|
||||
/* have seen tarballs with size field containing
|
||||
* the size of the link target's name */
|
||||
size0:
|
||||
file_header->size = 0;
|
||||
break;
|
||||
case '3':
|
||||
file_header->mode |= S_IFCHR;
|
||||
break;
|
||||
goto size0; /* paranoia */
|
||||
case '4':
|
||||
file_header->mode |= S_IFBLK;
|
||||
break;
|
||||
goto size0;
|
||||
case '5':
|
||||
set_dir:
|
||||
file_header->mode |= S_IFDIR;
|
||||
break;
|
||||
goto size0;
|
||||
case '6':
|
||||
file_header->mode |= S_IFIFO;
|
||||
break;
|
||||
goto size0;
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
case 'L':
|
||||
/* free: paranoia: tar with several consecutive longnames */
|
||||
|
@ -8,7 +8,9 @@
|
||||
|
||||
void FAST_FUNC seek_by_jump(const archive_handle_t *archive_handle, unsigned amount)
|
||||
{
|
||||
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
|
||||
if (amount
|
||||
&& lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1
|
||||
) {
|
||||
if (errno == ESPIPE)
|
||||
seek_by_read(archive_handle, amount);
|
||||
else
|
||||
|
27
testsuite/tar/tar_with_link_with_size
Normal file
27
testsuite/tar/tar_with_link_with_size
Normal file
@ -0,0 +1,27 @@
|
||||
# This tarball contains a softlink with size field != 0.
|
||||
# If not ignored, it makes hext header to be skipped
|
||||
# and data to be read as a header.
|
||||
# GNU tar 1.15.1 has a bug here: tf won't work, but xf will.
|
||||
tar1_bz2()
|
||||
{
|
||||
$ECHO -ne "\x42\x5a\x68\x39\x31\x41\x59\x26\x53\x59\x14\x44\xe3\xdd\x00\x00"
|
||||
$ECHO -ne "\x9a\xfb\x90\xca\x18\x00\xc0\x40\x03\xff\x80\x08\x00\x7b\xe3\xff"
|
||||
$ECHO -ne "\x80\x04\x00\x00\x08\x30\x00\xd6\xb3\x09\x45\x19\x0d\x0d\x41\x84"
|
||||
$ECHO -ne "\x1a\x68\xd0\x7a\x99\x90\x4a\x0a\x6d\x4c\xa3\x20\x7a\x41\xa0\x00"
|
||||
$ECHO -ne "\x00\x55\x25\x34\x1a\x34\xd0\x00\x64\x64\x1a\x32\x3f\x76\x3c\x1c"
|
||||
$ECHO -ne "\xd3\x3c\xa0\x84\x9b\x88\x05\x70\x90\xbb\x18\x28\x39\x29\xb3\x30"
|
||||
$ECHO -ne "\xa8\x0a\x21\x70\x0c\x01\x32\x3b\xbe\xde\xd7\x13\x2e\xbd\x2a\x9c"
|
||||
$ECHO -ne "\xa8\x42\x2a\x91\x15\xe2\xa1\xcd\x24\x37\x9c\x91\xaa\xc7\x14\xdb"
|
||||
$ECHO -ne "\x4c\x08\xaa\xaf\x12\xeb\x6c\x37\x96\xb0\xa4\x25\x0c\xb4\x4b\xc5"
|
||||
$ECHO -ne "\x52\x70\x3b\x25\x4c\x0e\x46\x67\x51\x54\x89\x13\x13\xf0\xa8\xe9"
|
||||
$ECHO -ne "\x68\x4e\x8c\x81\xfc\x79\xe0\xb0\xd8\x79\x34\x94\x71\xa2\x0c\xbe"
|
||||
$ECHO -ne "\x93\x61\x82\x95\x10\x88\xd1\xa6\x69\xaa\x38\x9c\xb6\xc2\xb2\x94"
|
||||
$ECHO -ne "\x90\xc3\x82\x29\xe8\x8c\xb8\x95\x83\x32\x40\x61\x11\x11\xd3\xaa"
|
||||
$ECHO -ne "\x3f\x8b\xb9\x22\x9c\x28\x48\x0a\x22\x71\xee\x80"
|
||||
}
|
||||
res1="\
|
||||
lrwxrwxrwx user/group 0 2008-07-19 15:02:37 firmware-372/sources/native/bin/chroot-setup.sh -> qemu-setup.sh
|
||||
-rwxr-xr-x user/group 512 2008-07-19 15:02:37 firmware-372/sources/native/bin/qemu-setup.sh"
|
||||
|
||||
t=`tar1_bz2 | bunzip2 | busybox tar tvf -`
|
||||
test x"$res1" = x"$t"
|
Loading…
x
Reference in New Issue
Block a user