]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
cpio: Add afio header split test
authorTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 29 May 2026 21:36:44 +0000 (23:36 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 30 May 2026 19:58:51 +0000 (21:58 +0200)
Verify that afio headers are detected even on unfortunate filter read
splits, i.e. when magic is found but rest of header has yet to be
retrieved.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Makefile.am
libarchive/test/test_read_format_cpio_afio.c
libarchive/test/test_read_format_cpio_afio_header.part1.cpio.uu [new file with mode: 0644]
libarchive/test/test_read_format_cpio_afio_header.part2.cpio.uu [new file with mode: 0644]

index 9d9a637a9797ec41a86ceeea2b89150aa63d3102..feee8b399a8f9b2265c0d0757a3681119a951c6a 100644 (file)
@@ -897,6 +897,8 @@ libarchive_test_EXTRA_DIST=\
        libarchive/test/test_read_format_cab_filename_cp932.cab.uu \
        libarchive/test/test_read_format_cab_lzx_oob.cab.uu \
        libarchive/test/test_read_format_cab_skip_malformed.cab.uu \
+       libarchive/test/test_read_format_cpio_afio_header.part1.cpio.uu \
+       libarchive/test/test_read_format_cpio_afio_header.part2.cpio.uu \
        libarchive/test/test_read_format_cpio_bin_be.cpio.uu \
        libarchive/test/test_read_format_cpio_bin_le.cpio.uu \
        libarchive/test/test_read_format_cpio_filename_cp866.cpio.uu \
index be386e1f40c3fa1b524c288f646cc842b18976aa..a1fb683e38d49857b1fee632c80d0fb84e561075 100644 (file)
@@ -125,3 +125,27 @@ DEFINE_TEST(test_read_format_cpio_afio_broken)
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_AFIO_LARGE);
        archive_read_free(a);
 }
+
+DEFINE_TEST(test_read_format_cpio_afio_header)
+{
+  const char *reffiles[] =
+  {
+    "test_read_format_cpio_afio_header.part1.cpio",
+    "test_read_format_cpio_afio_header.part2.cpio",
+    NULL
+  };
+  struct archive_entry *ae;
+  struct archive *a;
+
+  extract_reference_files(reffiles);
+  assert((a = archive_read_new()) != NULL);
+  assertA(0 == archive_read_support_format_cpio(a));
+  assertA(0 == archive_read_open_filenames(a, reffiles, 10240));
+
+  /* File "a" */
+  assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+  assertEqualString("a", archive_entry_pathname(ae));
+
+  assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+  assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/libarchive/test/test_read_format_cpio_afio_header.part1.cpio.uu b/libarchive/test/test_read_format_cpio_afio_header.part1.cpio.uu
new file mode 100644 (file)
index 0000000..0d06cb2
--- /dev/null
@@ -0,0 +1,5 @@
+begin 644 test_read_format_cpio_afio_header.part1.cpio
+M,#<P-S(W,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P;3`P,#`P,#`P,#`P,#`P
+?,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,```
+`
+end
diff --git a/libarchive/test/test_read_format_cpio_afio_header.part2.cpio.uu b/libarchive/test/test_read_format_cpio_afio_header.part2.cpio.uu
new file mode 100644 (file)
index 0000000..0a3d595
--- /dev/null
@@ -0,0 +1,4 @@
+begin 644 test_read_format_cpio_afio_header.part2.cpio
+I,#`P,#`P,#`P;C`P,#$P,#`P,#`P,',P,#`P,#`P,#`P,#`P,#`P.F$`
+`
+end