]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Extend the MacOS compatibility test to verify that the attribute blob
authorTim Kientzle <kientzle@gmail.com>
Sat, 25 Jun 2011 23:33:15 +0000 (19:33 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sat, 25 Jun 2011 23:33:15 +0000 (19:33 -0400)
starts with the expected bytes.
Fix the bug that this uncovered.

SVN-Revision: 3423

libarchive/archive_read_support_format_tar.c
libarchive/test/test_compat_mac.c

index af1a7b64eb90aafe6488e9c8464683e07bd35792..fc9c0725350fb75ee516e8ccc802267bb85fcac7 100644 (file)
@@ -1300,9 +1300,7 @@ read_mac_metadata_blob(struct archive_read *a, struct tar *tar,
 
        /* Read the body as a Mac OS metadata blob. */
        size = archive_entry_size(entry);
-       *unconsumed = (size + 511) & ~ 511;
 
-       tar_flush_unconsumed(a, unconsumed);
        /*
         * TODO: Look beyond the body here to peek at the next header.
         * If it's a regular header (not an extension header)
@@ -1321,6 +1319,8 @@ read_mac_metadata_blob(struct archive_read *a, struct tar *tar,
                return (ARCHIVE_FATAL);
        }
        archive_entry_copy_mac_metadata(entry, data, size);
+       *unconsumed = (size + 511) & ~ 511;
+       tar_flush_unconsumed(a, unconsumed);
        return (tar_read_header(a, tar, entry, unconsumed));
 }
 
index 66996f20d70e805a3165a9b68ae8e4114b82794e..0149d2ecb9b70b14abde4f24669c236a7682a035 100644 (file)
@@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$");
        "abcdefghijklmnopqrstuvwxyz/"
 
 /*
- * Apple shipped an extended version of GNU tar with Mac OX X 10.5
+ * Apple shipped an extended version of GNU tar with Mac OS X 10.5
  * and earlier.
  */
 void test_compat_mac_1()
@@ -103,6 +103,7 @@ void test_compat_mac_1()
        attr = archive_entry_mac_metadata(ae, &attrSize);
        assert(attr != NULL);
        assertEqualInt(225, attrSize);
+       assertEqualMem("\x00\x05\x16\x07\x00\x02\x00\x00Mac OS X", attr, 16);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("file", archive_entry_pathname(ae));
@@ -116,6 +117,7 @@ void test_compat_mac_1()
        attr = archive_entry_mac_metadata(ae, &attrSize);
        assert(attr != NULL);
        assertEqualInt(225, attrSize);
+       assertEqualMem("\x00\x05\x16\x07\x00\x02\x00\x00Mac OS X", attr, 16);
 
        /* Verify the end-of-archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
@@ -136,6 +138,8 @@ void test_compat_mac_2()
        char name[] = "test_compat_mac-2.tar.Z";
        struct archive_entry *ae;
        struct archive *a;
+       const void *attr;
+       size_t attrSize;
 
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
@@ -152,6 +156,10 @@ void test_compat_mac_2()
        assertEqualString("staff", archive_entry_gname(ae));
        assertEqualInt(040755, archive_entry_mode(ae));
 
+       attr = archive_entry_mac_metadata(ae, &attrSize);
+       assert(attr == NULL);
+       assertEqualInt(0, attrSize);
+
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("./mydir/", archive_entry_pathname(ae));
        assertEqualInt(1303628303, archive_entry_mtime(ae));
@@ -161,6 +169,11 @@ void test_compat_mac_2()
        assertEqualString("staff", archive_entry_gname(ae));
        assertEqualInt(040755, archive_entry_mode(ae));
 
+       attr = archive_entry_mac_metadata(ae, &attrSize);
+       assert(attr != NULL);
+       assertEqualInt(267, attrSize);
+       assertEqualMem("\x00\x05\x16\x07\x00\x02\x00\x00Mac OS X", attr, 16);
+
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("./myfile", archive_entry_pathname(ae));
        assertEqualInt(1303628303, archive_entry_mtime(ae));
@@ -170,6 +183,11 @@ void test_compat_mac_2()
        assertEqualString("staff", archive_entry_gname(ae));
        assertEqualInt(0100644, archive_entry_mode(ae));
 
+       attr = archive_entry_mac_metadata(ae, &attrSize);
+       assert(attr != NULL);
+       assertEqualInt(267, attrSize);
+       assertEqualMem("\x00\x05\x16\x07\x00\x02\x00\x00Mac OS X", attr, 16);
+
        /* Verify the end-of-archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));