From: Martin Matuska Date: Wed, 3 Apr 2024 09:15:22 +0000 (+0200) Subject: Revert "zip: update AppleDouble support for directories (#2100)" X-Git-Tag: v3.7.3~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62c8caf6611a7d0662d80176c4fdb40f85794699;p=thirdparty%2Flibarchive.git Revert "zip: update AppleDouble support for directories (#2100)" This reverts commit 390d83012fdba8c8db7fc9915338805882b0597a. PR reopened back for review. --- diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c index d7b6f082e..212bfff9f 100644 --- a/libarchive/archive_read_support_format_zip.c +++ b/libarchive/archive_read_support_format_zip.c @@ -4083,17 +4083,6 @@ slurp_central_directory(struct archive_read *a, struct archive_entry* entry, } else { /* Generate resource fork name to find its * resource file at zip->tree_rsrc. */ - - /* If this is an entry ending with slash, - * make the resource for name slash-less - * as the actual resource fork doesn't end with '/'. - */ - size_t tmp_length = filename_length; - if (name[tmp_length - 1] == '/') { - tmp_length--; - r = rsrc_basename(name, tmp_length); - } - archive_strcpy(&(zip_entry->rsrcname), "__MACOSX/"); archive_strncat(&(zip_entry->rsrcname), @@ -4101,7 +4090,7 @@ slurp_central_directory(struct archive_read *a, struct archive_entry* entry, archive_strcat(&(zip_entry->rsrcname), "._"); archive_strncat(&(zip_entry->rsrcname), name + (r - name), - tmp_length - (r - name)); + filename_length - (r - name)); /* Register an entry to RB tree to sort it by * file offset. */ __archive_rb_tree_insert_node(&zip->tree, diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c index 92db4ff05..58265ee0d 100644 --- a/libarchive/archive_write_disk_posix.c +++ b/libarchive/archive_write_disk_posix.c @@ -4427,8 +4427,7 @@ fixup_appledouble(struct archive_write_disk *a, const char *pathname) #else la_stat(datafork.s, &st) == -1 || #endif - (((st.st_mode & AE_IFMT) != AE_IFREG) && - ((st.st_mode & AE_IFMT) != AE_IFDIR))) + (st.st_mode & AE_IFMT) != AE_IFREG) goto skip_appledouble; /* diff --git a/libarchive/test/test_write_disk_appledouble.c b/libarchive/test/test_write_disk_appledouble.c index 8de6c8b50..3265a94d2 100644 --- a/libarchive/test/test_write_disk_appledouble.c +++ b/libarchive/test/test_write_disk_appledouble.c @@ -236,87 +236,3 @@ DEFINE_TEST(test_write_disk_appledouble) assertEqualFile("hfscmp/file3", "nocmp/file3"); #endif } - -/* Test writing apple doubles to disk from zip format */ -DEFINE_TEST(test_write_disk_appledouble_zip) -{ -#if !defined(__APPLE__) || !defined(UF_COMPRESSED) || !defined(HAVE_SYS_XATTR_H)\ - || !defined(HAVE_ZLIB_H) - skipping("MacOS-specific AppleDouble test"); -#else - const char *refname = "test_write_disk_appledouble_zip.zip"; - struct archive *ad, *a; - struct archive_entry *ae; - struct stat st; - - extract_reference_file(refname); - - /* - * Extract an archive to disk. - */ - assert((ad = archive_write_disk_new()) != NULL); - assertEqualIntA(ad, ARCHIVE_OK, - archive_write_disk_set_standard_lookup(ad)); - assertEqualIntA(ad, ARCHIVE_OK, - archive_write_disk_set_options(ad, - ARCHIVE_EXTRACT_TIME | - ARCHIVE_EXTRACT_SECURE_SYMLINKS | - ARCHIVE_EXTRACT_SECURE_NODOTDOT)); - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, - refname, 512 * 20)); - - /* Skip The top level directory */ - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString("apple_double_dir/", archive_entry_pathname(ae)); - - /* Extract apple_double_test */ - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString("apple_double_dir/apple_double_dir_test/", archive_entry_pathname(ae)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad)); - - /* Extract ._apple_double_dir_test which will be merged into apple_double_dir_test as metadata. */ - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString("apple_double_dir/._apple_double_dir_test", archive_entry_pathname(ae)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad)); - - /* Extract test_file */ - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString("apple_double_dir/test_file", archive_entry_pathname(ae)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad)); - - /* Extract ._test_file which will be merged into test_file as metadata. */ - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString("apple_double_dir/._test_file", archive_entry_pathname(ae)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad)); - - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_free(a)); - assertEqualIntA(ad, ARCHIVE_OK, archive_write_free(ad)); - - /* Test test_file */ - assertEqualInt(0, stat("apple_double_dir/test_file", &st)); - assertFileSize("apple_double_dir/test_file", 5); - failure("'%s' should have Resource Fork", "test_file"); - assertEqualInt(1, has_xattr("apple_double_dir/test_file", "com.apple.ResourceFork")); - - /* Test apple_double_dir_test */ - failure("'%s' should have quarantine xattr", "apple_double_dir_test"); - assertEqualInt(1, has_xattr("apple_double_dir/apple_double_dir_test", "com.apple.quarantine")); - - /* Test ._test_file. */ - failure("'apple_double_dir/._test_file' should be merged and removed"); - assertFileNotExists("apple_double_dir/._test_file"); - - /* Test ._apple_double_dir_test */ - failure("'apple_double_dir/._._apple_double_dir_test' should be merged and removed"); - assertFileNotExists("apple_double_dir/._apple_double_dir_test"); - - assertChdir(".."); - -#endif -} diff --git a/libarchive/test/test_write_disk_appledouble_zip.zip.uu b/libarchive/test/test_write_disk_appledouble_zip.zip.uu deleted file mode 100644 index 5ab67533d..000000000 --- a/libarchive/test/test_write_disk_appledouble_zip.zip.uu +++ /dev/null @@ -1,27 +0,0 @@ -begin 644 test_write_disk_appledouble_zip.zip -M4$L#!`H```````MM?%@````````````````1`!``87!P;&5?9&]U8FQE7V1I -M