]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Clear the ZIP format name before constructing a new one, so it isn't appended to... 961/head
authorZack Weger <ZWeger@StrozFriedberg.com>
Fri, 20 Oct 2017 18:09:23 +0000 (14:09 -0400)
committerZack Weger <ZWeger@StrozFriedberg.com>
Fri, 20 Oct 2017 18:09:23 +0000 (14:09 -0400)
libarchive/archive_read_support_format_zip.c
libarchive/test/test_read_format_zip.c

index 125f1838c540947240313d983ad08cf9fa94bb34..69e388ead3c664729ed35345e8317715deed5e87 100644 (file)
@@ -1061,6 +1061,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
                zip->end_of_entry = 1;
 
        /* Set up a more descriptive format name. */
+        archive_string_empty(&zip->format_name);
        archive_string_sprintf(&zip->format_name, "ZIP %d.%d (%s)",
            version / 10, version % 10,
            compression_name(zip->entry->compression));
index cea2676f3ea68362c26193e88a5f231955320a47..6cc25a6676fcfdd8a713a521a011990850098818 100644 (file)
@@ -41,6 +41,7 @@ verify_basic(struct archive *a, int seek_checks)
        int64_t o;
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+        assertEqualString("ZIP 1.0 (uncompressed)", archive_format_name(a));
        assertEqualString("dir/", archive_entry_pathname(ae));
        assertEqualInt(1179604249, archive_entry_mtime(ae));
        assertEqualInt(0, archive_entry_size(ae));
@@ -53,6 +54,7 @@ verify_basic(struct archive *a, int seek_checks)
        assertEqualInt((int)s, 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+        assertEqualString("ZIP 2.0 (deflation)", archive_format_name(a));
        assertEqualString("file1", archive_entry_pathname(ae));
        assertEqualInt(1179604289, archive_entry_mtime(ae));
        if (seek_checks)
@@ -72,6 +74,7 @@ verify_basic(struct archive *a, int seek_checks)
        }
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+        assertEqualString("ZIP 2.0 (deflation)", archive_format_name(a));
        assertEqualString("file2", archive_entry_pathname(ae));
        assertEqualInt(1179605932, archive_entry_mtime(ae));
        assertEqualInt(archive_entry_is_encrypted(ae), 0);
@@ -93,6 +96,7 @@ verify_basic(struct archive *a, int seek_checks)
                assert(archive_errno(a) != 0);
        }
        assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
+        assertEqualString("ZIP 2.0 (deflation)", archive_format_name(a));
        /* Verify the number of files read. */
        failure("the archive file has three files");
        assertEqualInt(3, archive_file_count(a));