From: Tobias Stoeckmann Date: Fri, 15 May 2026 15:07:27 +0000 (+0200) Subject: read: Add multi-volume regression test X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=515380e7e5df4f2cf8fc9228d376ba34065a7ab2;p=thirdparty%2Flibarchive.git read: Add multi-volume regression test 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 --- diff --git a/Makefile.am b/Makefile.am index cf54b4e54..e800a978d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/libarchive/test/CMakeLists.txt b/libarchive/test/CMakeLists.txt index f6f5beba7..75349e238 100644 --- a/libarchive/test/CMakeLists.txt +++ b/libarchive/test/CMakeLists.txt @@ -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 index 000000000..8fc19d086 --- /dev/null +++ b/libarchive/test/test_read_files_compressed.c @@ -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 index 000000000..346545a0d --- /dev/null +++ b/libarchive/test/test_read_files_compressed.part01.uu @@ -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 index 000000000..41e440391 --- /dev/null +++ b/libarchive/test/test_read_files_compressed.part02.uu @@ -0,0 +1,4 @@ +begin 644 test_read_files_compressed.part02 +!```` +` +end