From 75a0e2ca19464e66c68523e0cda012516cd1816d Mon Sep 17 00:00:00 2001 From: Zack Weger Date: Fri, 20 Oct 2017 14:09:23 -0400 Subject: [PATCH] Clear the ZIP format name before constructing a new one, so it isn't appended to the format name of the previous entry --- libarchive/archive_read_support_format_zip.c | 1 + libarchive/test/test_read_format_zip.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c index 125f1838c..69e388ead 100644 --- a/libarchive/archive_read_support_format_zip.c +++ b/libarchive/archive_read_support_format_zip.c @@ -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)); diff --git a/libarchive/test/test_read_format_zip.c b/libarchive/test/test_read_format_zip.c index cea2676f3..6cc25a667 100644 --- a/libarchive/test/test_read_format_zip.c +++ b/libarchive/test/test_read_format_zip.c @@ -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)); -- 2.39.2