]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
7zip: add ArchiveProperties payload test
authordatauwu <datauwu@users.noreply.github.com>
Fri, 3 Jul 2026 17:16:18 +0000 (01:16 +0800)
committerdatauwu <datauwu@users.noreply.github.com>
Fri, 3 Jul 2026 17:44:58 +0000 (01:44 +0800)
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.

Makefile.am
libarchive/test/test_read_format_7zip.c
libarchive/test/test_read_format_7zip_archive_properties.7z.uu [new file with mode: 0644]

index 98f3da98007e43ed9821a8a5d984958f0fb02321..c149fb65bd77a7e29ec147905d80dd00c7abf47b 100644 (file)
@@ -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 \
index 3979ba0512cc4cc5f84787262b1ad2517523433c..66b5930e43192f0310cbde466c3569fa6545f0b1 100644 (file)
@@ -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 (file)
index 0000000..b5759d9
--- /dev/null
@@ -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