From: Michihiro NAKAJIMA Date: Sun, 27 Sep 2009 11:43:22 +0000 (-0400) Subject: Fix reading symbolic link names from a iso image. X-Git-Tag: v2.8.0~331 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7440e0ed4d994312138898295fc0fbb12df1599;p=thirdparty%2Flibarchive.git Fix reading symbolic link names from a iso image. see below here. -- How to make a iso image of this case. %mkdir dir %ln -s /tmp//foo dir/symlink1 %ln -s /tmp/foo///bar dir/symlink2 %ls -la dir total 4 drwxr-xr-x 2 xxx xxx 512 9 20 15:09 . drwxr-xr-x 16 xxx xxx 1024 9 20 15:09 .. lrwxr-xr-x 1 xxx xxx 9 9 20 15:09 symlink1 -> /tmp//foo lrwxr-xr-x 1 xxx xxx 14 9 20 15:09 symlink2 -> /tmp/foo///bar %mkisofs -R -o test.iso dir Total translation table size: 0 Total rockridge attributes bytes: 374 Total directory bytes: 0 Path table size(bytes): 10 Max brk space used 3b524 175 extents written (0 MB) -- On FreeBSD8. # mount -t cd9660 /dev/`mdconfig -f test.iso` /mnt # ls -la /mnt total 4 drwxr-xr-x 2 xxx xxx 2048 9 20 15:09 . drwxr-xr-x 20 daemon kmem 512 9 15 13:33 .. lrwxr-xr-x 1 xxx xxx 9 9 20 15:09 symlink1 -> /tmp//foo lrwxr-xr-x 1 xxx xxx 14 9 20 15:09 symlink2 -> /tmp/foo///bar -- bsdtar cannot handle this case. %bsdtar tvf test.iso drwx------ 0 0 0 2048 9 20 15:09 . lrwxr-xr-x 1 1001 1001 0 9 20 15:09 symlink1 -> /foo lrwxr-xr-x 1 1001 1001 0 9 20 15:09 symlink2 -> /bar The ROOT component does not appear at the first component only. mkisofs inserts ROOT components into among other components. components of 'SL' System Use Entry of /tmp//foo are: flg len +----+----+ | 08 | 00 | ROOT component. +----+----+ +----+----+----+----+----+ | 00 | 03 | 't'| 'm'| 'p'| +----+----+----+----+----+ +----+----+ | 08 | 00 | ROOT component. +----+----+ +----+----+----+----+----+ | 00 | 03 | 'f'| 'o'| 'o'| +----+----+----+----+----+ components of 'SL' System Use Entry of /tmp/foo///bar are: flg len +----+----+ | 08 | 00 | ROOT component. +----+----+ +----+----+----+----+----+ | 00 | 03 | 't'| 'm'| 'p'| +----+----+----+----+----+ +----+----+----+----+----+ | 00 | 03 | 'f'| 'o'| 'o'| +----+----+----+----+----+ +----+----+ | 08 | 00 | ROOT component. +----+----+ +----+----+ | 08 | 00 | ROOT component. +----+----+ +----+----+----+----+----+ | 00 | 03 | 'b'| 'a'| 'r'| +----+----+----+----+----+ SVN-Revision: 1477 --- diff --git a/libarchive/archive_read_support_format_iso9660.c b/libarchive/archive_read_support_format_iso9660.c index b9a5f4dc6..c83ddfaaa 100644 --- a/libarchive/archive_read_support_format_iso9660.c +++ b/libarchive/archive_read_support_format_iso9660.c @@ -1602,7 +1602,6 @@ parse_rockridge_SL1(struct file_info *file, const unsigned char *data, archive_strcat(&file->symlink, ".."); break; case 0x08: /* Root of filesystem. */ - archive_string_empty(&file->symlink); archive_strcat(&file->symlink, "/"); separator = ""; break; diff --git a/libarchive/test/test_read_format_isorr_bz2.c b/libarchive/test/test_read_format_isorr_bz2.c index 1e5b51963..a8212dbb8 100644 --- a/libarchive/test/test_read_format_isorr_bz2.c +++ b/libarchive/test/test_read_format_isorr_bz2.c @@ -39,6 +39,8 @@ ln /tmp/iso/file /tmp/iso/hardlink (cd /tmp/iso; ln -s /tmp/ symlink2) (cd /tmp/iso; ln -s /tmp/../ symlink3) (cd /tmp/iso; ln -s .././../tmp/ symlink4) +(cd /tmp/iso; ln -s .///file symlink5) +(cd /tmp/iso; ln -s /tmp//../ symlink6) TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/file /tmp/iso/dir TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink mkhybrid -R -uid 1 -gid 2 /tmp/iso | bzip2 > test_read_format_isorr_bz2.iso.bz2 @@ -73,7 +75,7 @@ DEFINE_TEST(test_read_format_isorr_bz2) /* Retrieve each of the 8 files on the ISO image and * verify that each one is what we expect. */ - for (i = 0; i < 8; ++i) { + for (i = 0; i < 10; ++i) { assertEqualInt(0, archive_read_next_header(a, &ae)); if (strcmp(".", archive_entry_pathname(ae)) == 0) { @@ -164,6 +166,25 @@ DEFINE_TEST(test_read_format_isorr_bz2) assertEqualInt(1, archive_entry_stat(ae)->st_nlink); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); + } else if (strcmp("symlink5", archive_entry_pathname(ae)) == 0) { + /* A symlink to the regular file with "/" components. */ + assertEqualInt(AE_IFLNK, archive_entry_filetype(ae)); + assertEqualString(".///file", archive_entry_symlink(ae)); + assertEqualInt(0, archive_entry_size(ae)); + assertEqualInt(172802, archive_entry_mtime(ae)); + assertEqualInt(172802, archive_entry_atime(ae)); + assertEqualInt(1, archive_entry_stat(ae)->st_nlink); + assertEqualInt(1, archive_entry_uid(ae)); + assertEqualInt(2, archive_entry_gid(ae)); + } else if (strcmp("symlink6", archive_entry_pathname(ae)) == 0) { + /* A symlink to /tmp//.. + * (with "/" and ".." components) */ + assertEqualInt(AE_IFLNK, archive_entry_filetype(ae)); + assertEqualString("/tmp//..", archive_entry_symlink(ae)); + assertEqualInt(0, archive_entry_size(ae)); + assertEqualInt(1, archive_entry_stat(ae)->st_nlink); + assertEqualInt(1, archive_entry_uid(ae)); + assertEqualInt(2, archive_entry_gid(ae)); } else { failure("Saw a file that shouldn't have been there"); assertEqualString(archive_entry_pathname(ae), ""); diff --git a/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu b/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu index fe2cad906..35bd49911 100644 --- a/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu +++ b/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu @@ -1,25 +1,26 @@ begin 644 test_read_format_isorr_bz2.iso.bz2 -M0EIH.3%!629364.3#=@``-+_W?__2_358_WZ/__?8*?OWB8A_B2```4@`,0" -M@0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