aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-20 17:10:43 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-20 17:10:43 +0000
commitadc772a5f2b5b74f398aaa59c36739fee4ee7a85 (patch)
treec523a374fd7e9ec52fc935fa84f85dd068723998
parentb9bbc40f64f305dd09d8f3f31eb5632521f87f0c (diff)
downloadbusybox-w32-adc772a5f2b5b74f398aaa59c36739fee4ee7a85.tar.gz
busybox-w32-adc772a5f2b5b74f398aaa59c36739fee4ee7a85.tar.bz2
busybox-w32-adc772a5f2b5b74f398aaa59c36739fee4ee7a85.zip
tar: fix handling of tarballs with symlinks with size field != 0
-rw-r--r--archival/libunarchive/get_header_tar.c17
-rw-r--r--archival/libunarchive/seek_by_jump.c4
-rw-r--r--testsuite/tar/tar_with_link_with_size27
3 files changed, 41 insertions, 7 deletions
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index 7e3c482df..e7a3aeeb3 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -266,26 +266,31 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
266 case '0': 266 case '0':
267#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY 267#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
268 if (last_char_is(file_header->name, '/')) { 268 if (last_char_is(file_header->name, '/')) {
269 file_header->mode |= S_IFDIR; 269 goto set_dir;
270 } else 270 }
271#endif 271#endif
272 file_header->mode |= S_IFREG; 272 file_header->mode |= S_IFREG;
273 break; 273 break;
274 case '2': 274 case '2':
275 file_header->mode |= S_IFLNK; 275 file_header->mode |= S_IFLNK;
276 /* have seen tarballs with size field containing
277 * the size of the link target's name */
278 size0:
279 file_header->size = 0;
276 break; 280 break;
277 case '3': 281 case '3':
278 file_header->mode |= S_IFCHR; 282 file_header->mode |= S_IFCHR;
279 break; 283 goto size0; /* paranoia */
280 case '4': 284 case '4':
281 file_header->mode |= S_IFBLK; 285 file_header->mode |= S_IFBLK;
282 break; 286 goto size0;
283 case '5': 287 case '5':
288 set_dir:
284 file_header->mode |= S_IFDIR; 289 file_header->mode |= S_IFDIR;
285 break; 290 goto size0;
286 case '6': 291 case '6':
287 file_header->mode |= S_IFIFO; 292 file_header->mode |= S_IFIFO;
288 break; 293 goto size0;
289#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS 294#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
290 case 'L': 295 case 'L':
291 /* free: paranoia: tar with several consecutive longnames */ 296 /* free: paranoia: tar with several consecutive longnames */
diff --git a/archival/libunarchive/seek_by_jump.c b/archival/libunarchive/seek_by_jump.c
index 031598e7a..0a259c963 100644
--- a/archival/libunarchive/seek_by_jump.c
+++ b/archival/libunarchive/seek_by_jump.c
@@ -8,7 +8,9 @@
8 8
9void FAST_FUNC seek_by_jump(const archive_handle_t *archive_handle, unsigned amount) 9void FAST_FUNC seek_by_jump(const archive_handle_t *archive_handle, unsigned amount)
10{ 10{
11 if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) { 11 if (amount
12 && lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1
13 ) {
12 if (errno == ESPIPE) 14 if (errno == ESPIPE)
13 seek_by_read(archive_handle, amount); 15 seek_by_read(archive_handle, amount);
14 else 16 else
diff --git a/testsuite/tar/tar_with_link_with_size b/testsuite/tar/tar_with_link_with_size
new file mode 100644
index 000000000..40454f21c
--- /dev/null
+++ b/testsuite/tar/tar_with_link_with_size
@@ -0,0 +1,27 @@
1# This tarball contains a softlink with size field != 0.
2# If not ignored, it makes hext header to be skipped
3# and data to be read as a header.
4# GNU tar 1.15.1 has a bug here: tf won't work, but xf will.
5tar1_bz2()
6{
7 $ECHO -ne "\x42\x5a\x68\x39\x31\x41\x59\x26\x53\x59\x14\x44\xe3\xdd\x00\x00"
8 $ECHO -ne "\x9a\xfb\x90\xca\x18\x00\xc0\x40\x03\xff\x80\x08\x00\x7b\xe3\xff"
9 $ECHO -ne "\x80\x04\x00\x00\x08\x30\x00\xd6\xb3\x09\x45\x19\x0d\x0d\x41\x84"
10 $ECHO -ne "\x1a\x68\xd0\x7a\x99\x90\x4a\x0a\x6d\x4c\xa3\x20\x7a\x41\xa0\x00"
11 $ECHO -ne "\x00\x55\x25\x34\x1a\x34\xd0\x00\x64\x64\x1a\x32\x3f\x76\x3c\x1c"
12 $ECHO -ne "\xd3\x3c\xa0\x84\x9b\x88\x05\x70\x90\xbb\x18\x28\x39\x29\xb3\x30"
13 $ECHO -ne "\xa8\x0a\x21\x70\x0c\x01\x32\x3b\xbe\xde\xd7\x13\x2e\xbd\x2a\x9c"
14 $ECHO -ne "\xa8\x42\x2a\x91\x15\xe2\xa1\xcd\x24\x37\x9c\x91\xaa\xc7\x14\xdb"
15 $ECHO -ne "\x4c\x08\xaa\xaf\x12\xeb\x6c\x37\x96\xb0\xa4\x25\x0c\xb4\x4b\xc5"
16 $ECHO -ne "\x52\x70\x3b\x25\x4c\x0e\x46\x67\x51\x54\x89\x13\x13\xf0\xa8\xe9"
17 $ECHO -ne "\x68\x4e\x8c\x81\xfc\x79\xe0\xb0\xd8\x79\x34\x94\x71\xa2\x0c\xbe"
18 $ECHO -ne "\x93\x61\x82\x95\x10\x88\xd1\xa6\x69\xaa\x38\x9c\xb6\xc2\xb2\x94"
19 $ECHO -ne "\x90\xc3\x82\x29\xe8\x8c\xb8\x95\x83\x32\x40\x61\x11\x11\xd3\xaa"
20 $ECHO -ne "\x3f\x8b\xb9\x22\x9c\x28\x48\x0a\x22\x71\xee\x80"
21}
22res1="\
23lrwxrwxrwx user/group 0 2008-07-19 15:02:37 firmware-372/sources/native/bin/chroot-setup.sh -> qemu-setup.sh
24-rwxr-xr-x user/group 512 2008-07-19 15:02:37 firmware-372/sources/native/bin/qemu-setup.sh"
25
26t=`tar1_bz2 | bunzip2 | busybox tar tvf -`
27test x"$res1" = x"$t"