]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
read: Add multi-volume regression test
authorTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 15 May 2026 15:07:27 +0000 (17:07 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 15 May 2026 16:18:26 +0000 (18:18 +0200)
Check that no memory corruption occurs when switching files which are
decompressed through filters.

Test case supplied by Stuart Wallace.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Makefile.am
libarchive/test/CMakeLists.txt
libarchive/test/test_read_files_compressed.c [new file with mode: 0644]
libarchive/test/test_read_files_compressed.part01.uu [new file with mode: 0644]
libarchive/test/test_read_files_compressed.part02.uu [new file with mode: 0644]

index cf54b4e5490bf8a9b19a688ae27cae5cf3020c5e..e800a978d036559a9b1fb907db624fcf71226959 100644 (file)
@@ -466,6 +466,7 @@ libarchive_test_SOURCES= \
        libarchive/test/test_read_disk_entry_from_file.c \
        libarchive/test/test_read_extract.c \
        libarchive/test/test_read_file_nonexistent.c \
+       libarchive/test/test_read_files_compressed.c \
        libarchive/test/test_read_filter_compress.c \
        libarchive/test/test_read_filter_grzip.c \
        libarchive/test/test_read_filter_gzip_recursive.c \
@@ -815,6 +816,8 @@ libarchive_test_EXTRA_DIST=\
        libarchive/test/test_rar_multivolume_uncompressed_files.part08.rar.uu \
        libarchive/test/test_rar_multivolume_uncompressed_files.part09.rar.uu \
        libarchive/test/test_rar_multivolume_uncompressed_files.part10.rar.uu \
+       libarchive/test/test_read_files_compressed.part01.uu \
+       libarchive/test/test_read_files_compressed.part02.uu \
        libarchive/test/test_read_filter_grzip.tar.grz.uu \
        libarchive/test/test_read_filter_gzip_recursive.gz.uu \
        libarchive/test/test_read_filter_lrzip.tar.lrz.uu \
index f6f5beba7880b6d49274722548634af42a94eab2..75349e238d1972806b47da3d1961e4e3b7e5e87b 100644 (file)
@@ -98,6 +98,7 @@ IF(ENABLE_TEST)
     test_read_disk_entry_from_file.c
     test_read_extract.c
     test_read_file_nonexistent.c
+    test_read_files_compressed.c
     test_read_filter_compress.c
     test_read_filter_grzip.c
     test_read_filter_gzip_recursive.c
diff --git a/libarchive/test/test_read_files_compressed.c b/libarchive/test/test_read_files_compressed.c
new file mode 100644 (file)
index 0000000..8fc19d0
--- /dev/null
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2026 Tobias Stoeckmann
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+
+DEFINE_TEST(test_read_files_compressed)
+{
+       const char *reffiles[] =
+       {
+               "test_read_files_compressed.part01",
+               "test_read_files_compressed.part02",
+               NULL
+       };
+
+       struct archive *a;
+       struct archive_entry *entry = NULL;
+
+       extract_reference_files(reffiles);
+       assert((a = archive_read_new()) != NULL);
+       assertA(0 == archive_read_support_filter_all(a));
+       assertA(0 == archive_read_support_format_all(a));
+       assertA(0 == archive_read_open_filenames(a, reffiles, 10240));
+
+       assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &entry));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/libarchive/test/test_read_files_compressed.part01.uu b/libarchive/test/test_read_files_compressed.part01.uu
new file mode 100644 (file)
index 0000000..346545a
--- /dev/null
@@ -0,0 +1,4 @@
+begin 644 test_read_files_compressed.part01
+"'YT`
+`
+end
diff --git a/libarchive/test/test_read_files_compressed.part02.uu b/libarchive/test/test_read_files_compressed.part02.uu
new file mode 100644 (file)
index 0000000..41e4403
--- /dev/null
@@ -0,0 +1,4 @@
+begin 644 test_read_files_compressed.part02
+!````
+`
+end