From: datauwu Date: Fri, 3 Jul 2026 17:16:18 +0000 (+0800) Subject: 7zip: add ArchiveProperties payload test X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=49a273e31408231177aacf2ee405baefb84babff;p=thirdparty%2Flibarchive.git 7zip: add ArchiveProperties payload test Add a 7z test archive with a non-empty ArchiveProperties payload. The archive has one empty file and an ArchiveProperties entry with a 1-byte payload. It is accepted by 7-Zip/7zz. This covers parsing when ArchiveProperties has payload bytes. --- diff --git a/Makefile.am b/Makefile.am index 98f3da980..c149fb65b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -863,6 +863,7 @@ libarchive_test_EXTRA_DIST=\ libarchive/test/test_read_format_7zip_delta4_lzma2.7z.uu \ libarchive/test/test_read_format_7zip_empty_archive.7z.uu \ libarchive/test/test_read_format_7zip_empty_file.7z.uu \ + libarchive/test/test_read_format_7zip_archive_properties.7z.uu \ libarchive/test/test_read_format_7zip_encryption.7z.uu \ libarchive/test/test_read_format_7zip_encryption_header.7z.uu \ libarchive/test/test_read_format_7zip_encryption_partially.7z.uu \ diff --git a/libarchive/test/test_read_format_7zip.c b/libarchive/test/test_read_format_7zip.c index 3979ba051..66b5930e4 100644 --- a/libarchive/test/test_read_format_7zip.c +++ b/libarchive/test/test_read_format_7zip.c @@ -160,6 +160,32 @@ test_empty_file(void) assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } +DEFINE_TEST(test_read_format_7zip_archive_properties) +{ + const char *refname = "test_read_format_7zip_archive_properties.7z"; + struct archive_entry *ae; + struct archive *a; + + extract_reference_file(refname); + + 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, 10240)); + + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString("empty", archive_entry_pathname(ae)); + assertEqualInt(0, archive_entry_size(ae)); + assertEqualInt(1, archive_file_count(a)); + + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + assertEqualIntA(a, ARCHIVE_FORMAT_7ZIP, archive_format(a)); + + assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} + /* * Extract an encoded file. * The header of the 7z archive files is not encoded. diff --git a/libarchive/test/test_read_format_7zip_archive_properties.7z.uu b/libarchive/test/test_read_format_7zip_archive_properties.7z.uu new file mode 100644 index 000000000..b5759d932 --- /dev/null +++ b/libarchive/test/test_read_format_7zip_archive_properties.7z.uu @@ -0,0 +1,5 @@ +begin 644 test_read_format_7zip_archive_properties.7z +M-WJ\KR<< ,=YJHC S '@@J#,! @$!J@ % 0X!@ \! +F@!$- &4 ;0!P '0 >0 !0* 0" UD J+*= 14& 0 @@*2! +` +end