aboutsummaryrefslogtreecommitdiffstats
path: root/libarchive/test
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2019-12-28 23:40:32 +0000
committerMartin Matuska <mm@FreeBSD.org>2019-12-28 23:40:32 +0000
commit6922acad9a482c17c7af1acdb4d11d03f19bb1dc (patch)
treeb7e2717582504805f31e2195f7c74c5d6fa82a45 /libarchive/test
parenta297901e6c90d415ac49c88002dd4e02dc49e32b (diff)
downloadsrc-6922acad9a482c17c7af1acdb4d11d03f19bb1dc.tar.gz
src-6922acad9a482c17c7af1acdb4d11d03f19bb1dc.zip
Update vendor/libarchive/dist to git 1dae5a549fe4ab99fd3a49a9edcf897a7b2b1844
Relevant vendor changes: Issue #351: Refactor and implement private state logic for write filters PR #1252: RAR5 reader - verify window size for solid files (OSS-Fuzz 15482) PR #1255: zip writer - don't append unused NUL for directories PR #1260: Fix sparse file offset overflow on 32-bit systems PR #1263: UNICODE filename support for reading lha/lzh format Issue #1276: Bugfix and optimize archive_wstring_append_from_mbs() PR #1288: Add the "xattrhdr" option to pax write options PR #1295: 7z reader - fix reading archives with digests in PackInfo PR #1296: RAR5 reader - verify window size for multivolume archives PR #1297: ZIP reader - support LZMA_STREAM_END marker in 'lzma alone' files Issue #1298: Fix a heap-buffer-overflow in archive_string_append_from_wcs() OSS-Fuzz 19360, 19362: LHA reader - plug two memory leaks on error Fix possible off-by-one when dealing with readlink(2)
Notes
Notes: svn path=/vendor/libarchive/dist/; revision=356163
Diffstat (limited to 'libarchive/test')
-rw-r--r--libarchive/test/CMakeLists.txt3
-rw-r--r--libarchive/test/test_open_failure.c16
-rw-r--r--libarchive/test/test_open_fd.c27
-rw-r--r--libarchive/test/test_pax_xattr_header.c130
-rw-r--r--libarchive/test/test_pax_xattr_header_all.tar.uu72
-rw-r--r--libarchive/test/test_pax_xattr_header_libarchive.tar.uu72
-rw-r--r--libarchive/test/test_pax_xattr_header_schily.tar.uu72
-rw-r--r--libarchive/test/test_read_disk_directory_traversals.c3
-rw-r--r--libarchive/test/test_read_format_7zip_packinfo_digests.7z.uu7
-rw-r--r--libarchive/test/test_read_format_7zip_packinfo_digests.c77
-rw-r--r--libarchive/test/test_read_format_lha_filename_utf16.c143
-rw-r--r--libarchive/test/test_read_format_lha_filename_utf16.lzh.uu19
-rw-r--r--libarchive/test/test_read_format_rar5.c90
-rw-r--r--libarchive/test/test_read_format_rar5_different_solid_window_size.rar.uu73
-rw-r--r--libarchive/test/test_read_format_rar5_different_winsize_on_merge.rar.uu16
-rw-r--r--libarchive/test/test_sparse_basic.c11
16 files changed, 776 insertions, 55 deletions
diff --git a/libarchive/test/CMakeLists.txt b/libarchive/test/CMakeLists.txt
index 2f451d2a0649..df34d3e3200b 100644
--- a/libarchive/test/CMakeLists.txt
+++ b/libarchive/test/CMakeLists.txt
@@ -82,6 +82,7 @@ IF(ENABLE_TEST)
test_open_file.c
test_open_filename.c
test_pax_filename_encoding.c
+ test_pax_xattr_header.c
test_read_data_large.c
test_read_disk.c
test_read_disk_directory_traversals.c
@@ -101,6 +102,7 @@ IF(ENABLE_TEST)
test_read_format_7zip_encryption_header.c
test_read_format_7zip_encryption_partially.c
test_read_format_7zip_malformed.c
+ test_read_format_7zip_packinfo_digests.c
test_read_format_ar.c
test_read_format_cab.c
test_read_format_cab_filename.c
@@ -141,6 +143,7 @@ IF(ENABLE_TEST)
test_read_format_lha.c
test_read_format_lha_bugfix_0.c
test_read_format_lha_filename.c
+ test_read_format_lha_filename_utf16.c
test_read_format_mtree.c
test_read_format_mtree_crash747.c
test_read_format_pax_bz2.c
diff --git a/libarchive/test/test_open_failure.c b/libarchive/test/test_open_failure.c
index 845486cf9216..5316a872b6a8 100644
--- a/libarchive/test/test_open_failure.c
+++ b/libarchive/test/test_open_failure.c
@@ -160,11 +160,11 @@ DEFINE_TEST(test_open_failure)
archive_write_open(a, &private, my_open, my_write, my_close));
assertEqualInt(1, private.open_called);
assertEqualInt(0, private.write_called);
- assertEqualInt(1, private.close_called);
+ assertEqualInt(0, private.close_called);
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
assertEqualInt(1, private.open_called);
assertEqualInt(0, private.write_called);
- assertEqualInt(1, private.close_called);
+ assertEqualInt(0, private.close_called);
memset(&private, 0, sizeof(private));
private.magic = MAGIC;
@@ -177,11 +177,11 @@ DEFINE_TEST(test_open_failure)
archive_write_open(a, &private, my_open, my_write, my_close));
assertEqualInt(1, private.open_called);
assertEqualInt(0, private.write_called);
- assertEqualInt(1, private.close_called);
+ assertEqualInt(0, private.close_called);
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
assertEqualInt(1, private.open_called);
assertEqualInt(0, private.write_called);
- assertEqualInt(1, private.close_called);
+ assertEqualInt(0, private.close_called);
memset(&private, 0, sizeof(private));
private.magic = MAGIC;
@@ -193,11 +193,11 @@ DEFINE_TEST(test_open_failure)
archive_write_open(a, &private, my_open, my_write, my_close));
assertEqualInt(1, private.open_called);
assertEqualInt(0, private.write_called);
- assertEqualInt(1, private.close_called);
+ assertEqualInt(0, private.close_called);
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
assertEqualInt(1, private.open_called);
assertEqualInt(0, private.write_called);
- assertEqualInt(1, private.close_called);
+ assertEqualInt(0, private.close_called);
memset(&private, 0, sizeof(private));
private.magic = MAGIC;
@@ -209,10 +209,10 @@ DEFINE_TEST(test_open_failure)
archive_write_open(a, &private, my_open, my_write, my_close));
assertEqualInt(1, private.open_called);
assertEqualInt(0, private.write_called);
- assertEqualInt(1, private.close_called);
+ assertEqualInt(0, private.close_called);
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
assertEqualInt(1, private.open_called);
assertEqualInt(0, private.write_called);
- assertEqualInt(1, private.close_called);
+ assertEqualInt(0, private.close_called);
}
diff --git a/libarchive/test/test_open_fd.c b/libarchive/test/test_open_fd.c
index ff5fab1ad45b..7da8b5ebcb56 100644
--- a/libarchive/test/test_open_fd.c
+++ b/libarchive/test/test_open_fd.c
@@ -42,6 +42,7 @@ DEFINE_TEST(test_open_fd)
struct archive_entry *ae;
struct archive *a;
int fd;
+ const char *skip_open_fd_err_test;
#if defined(__BORLANDC__)
fd = open("test.tar", O_RDWR | O_CREAT | O_BINARY);
@@ -116,16 +117,18 @@ DEFINE_TEST(test_open_fd)
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
close(fd);
-
- /*
- * Verify some of the error handling.
- */
- assert((a = archive_read_new()) != NULL);
- assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
- assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
- /* FD 100 shouldn't be open. */
- assertEqualIntA(a, ARCHIVE_FATAL,
- archive_read_open_fd(a, 100, 512));
- assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
- assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+ skip_open_fd_err_test = getenv("SKIP_OPEN_FD_ERR_TEST");
+ if(skip_open_fd_err_test == NULL) {
+ /*
+ * Verify some of the error handling.
+ */
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+ /* FD 100 shouldn't be open. */
+ assertEqualIntA(a, ARCHIVE_FATAL,
+ archive_read_open_fd(a, 100, 512));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+ }
}
diff --git a/libarchive/test/test_pax_xattr_header.c b/libarchive/test/test_pax_xattr_header.c
new file mode 100644
index 000000000000..d0394aa09eda
--- /dev/null
+++ b/libarchive/test/test_pax_xattr_header.c
@@ -0,0 +1,130 @@
+/*-
+ * Copyright (c) 2019 Martin Matuska
+ * 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"
+__FBSDID("$FreeBSD$");
+
+static struct archive_entry*
+create_archive_entry(void) {
+ struct archive_entry *ae;
+
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_atime(ae, 2, 20);
+ archive_entry_set_ctime(ae, 4, 40);
+ archive_entry_set_mtime(ae, 5, 50);
+ archive_entry_copy_pathname(ae, "file");
+ archive_entry_set_mode(ae, AE_IFREG | 0755);
+ archive_entry_set_nlink(ae, 2);
+ archive_entry_set_size(ae, 8);
+ archive_entry_xattr_add_entry(ae, "user.data1", "ABCDEFG", 7);
+ archive_entry_xattr_add_entry(ae, "user.data2", "XYZ", 3);
+
+ return (ae);
+}
+
+DEFINE_TEST(test_pax_xattr_header)
+{
+ static const char *reffiles[] = {
+ "test_pax_xattr_header_all.tar",
+ "test_pax_xattr_header_libarchive.tar",
+ "test_pax_xattr_header_schily.tar",
+ NULL
+ };
+ struct archive *a;
+ struct archive_entry *ae;
+
+ extract_reference_files(reffiles);
+
+ /* First archive, no options */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, 0, archive_write_set_format_pax(a));
+ assertEqualIntA(a, 0, archive_write_add_filter_none(a));
+ assertEqualInt(0,
+ archive_write_open_filename(a, "test1.tar"));
+ ae = create_archive_entry();
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+ assertEqualIntA(a, 8, archive_write_data(a, "12345678", 9));
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_free(a));
+
+ assertEqualFile("test1.tar","test_pax_xattr_header_all.tar");
+
+ /* Second archive, xattrheader=SCHILY */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, 0, archive_write_set_format_pax(a));
+ assertEqualIntA(a, 0, archive_write_add_filter_none(a));
+ assertEqualIntA(a, 0, archive_write_set_options(a,
+ "xattrheader=SCHILY"));
+ assertEqualInt(0,
+ archive_write_open_filename(a, "test2.tar"));
+
+ ae = create_archive_entry();
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+ assertEqualIntA(a, 8, archive_write_data(a, "12345678", 9));
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_free(a));
+
+ assertEqualFile("test2.tar","test_pax_xattr_header_schily.tar");
+
+ /* Third archive, xattrheader=LIBARCHIVE */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, 0, archive_write_set_format_pax(a));
+ assertEqualIntA(a, 0, archive_write_add_filter_none(a));
+ assertEqualIntA(a, 0, archive_write_set_options(a,
+ "xattrheader=LIBARCHIVE"));
+ assertEqualInt(0,
+ archive_write_open_filename(a, "test3.tar"));
+
+ ae = create_archive_entry();
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+ assertEqualIntA(a, 8, archive_write_data(a, "12345678", 9));
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_free(a));
+
+ assertEqualFile("test3.tar","test_pax_xattr_header_libarchive.tar");
+
+ /* Fourth archive, xattrheader=ALL */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, 0, archive_write_set_format_pax(a));
+ assertEqualIntA(a, 0, archive_write_add_filter_none(a));
+ assertEqualIntA(a, 0, archive_write_set_options(a, "xattrheader=ALL"));
+ assertEqualInt(0,
+ archive_write_open_filename(a, "test4.tar"));
+
+ ae = create_archive_entry();
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+ assertEqualIntA(a, 8, archive_write_data(a, "12345678", 9));
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_free(a));
+
+ assertEqualFile("test4.tar","test_pax_xattr_header_all.tar");
+}
diff --git a/libarchive/test/test_pax_xattr_header_all.tar.uu b/libarchive/test/test_pax_xattr_header_all.tar.uu
new file mode 100644
index 000000000000..086428e7144b
--- /dev/null
+++ b/libarchive/test/test_pax_xattr_header_all.tar.uu
@@ -0,0 +1,72 @@
+begin 644 test_pax_xattr_header_all.tar
+M4&%X2&5A9&5R+V9I;&4`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#<U-2``,#`P,#`P(``P,#`P,#`@`#`P,#`P,#`P,S$T
+M(#`P,#`P,#`P,#`U(#`Q,C`P-@`@>```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,```````
+M````````````````````````````````````````````````````````````
+M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````R,"!C=&EM93TT+C`P,#`P,#`T"C(P(&%T:6UE
+M/3(N,#`P,#`P,#(*,C`@;71I;64]-2XP,#`P,#`P-0HS-B!,24)!4D-(259%
+M+GAA='1R+G5S97(N9&%T83(]5T9L80HS,2!30TA)3%DN>&%T='(N=7-E<BYD
+M871A,CU865H*-#(@3$E"05)#2$E612YX871T<BYU<V5R+F1A=&$Q/5%52D12
+M159'4G<*,S4@4T-(24Q9+GAA='1R+G5S97(N9&%T83$]04)#1$5&1PH`````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&9I;&4`````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````````````````````````````P
+M,#`W-34@`#`P,#`P,"``,#`P,#`P(``P,#`P,#`P,#`Q,"`P,#`P,#`P,#`P
+M-2`P,3`P,C8`(#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(`,#``````````````````````
+M````````````````````````````````````````````````````````````
+M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````,3(S-#4V-S@`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+,````````````````
+`
+end
diff --git a/libarchive/test/test_pax_xattr_header_libarchive.tar.uu b/libarchive/test/test_pax_xattr_header_libarchive.tar.uu
new file mode 100644
index 000000000000..1d15980365c5
--- /dev/null
+++ b/libarchive/test/test_pax_xattr_header_libarchive.tar.uu
@@ -0,0 +1,72 @@
+begin 644 test_pax_xattr_header_libarchive.tar
+M4&%X2&5A9&5R+V9I;&4`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#<U-2``,#`P,#`P(``P,#`P,#`@`#`P,#`P,#`P,C$R
+M(#`P,#`P,#`P,#`U(#`Q,C`P,P`@>```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,```````
+M````````````````````````````````````````````````````````````
+M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````R,"!C=&EM93TT+C`P,#`P,#`T"C(P(&%T:6UE
+M/3(N,#`P,#`P,#(*,C`@;71I;64]-2XP,#`P,#`P-0HS-B!,24)!4D-(259%
+M+GAA='1R+G5S97(N9&%T83(]5T9L80HT,B!,24)!4D-(259%+GAA='1R+G5S
+M97(N9&%T83$]455*1%)%5D=2=PH`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&9I;&4`````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````````````````````````````P
+M,#`W-34@`#`P,#`P,"``,#`P,#`P(``P,#`P,#`P,#`Q,"`P,#`P,#`P,#`P
+M-2`P,3`P,C8`(#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(`,#``````````````````````
+M````````````````````````````````````````````````````````````
+M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````,3(S-#4V-S@`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+,````````````````
+`
+end
diff --git a/libarchive/test/test_pax_xattr_header_schily.tar.uu b/libarchive/test/test_pax_xattr_header_schily.tar.uu
new file mode 100644
index 000000000000..aafea17c54dd
--- /dev/null
+++ b/libarchive/test/test_pax_xattr_header_schily.tar.uu
@@ -0,0 +1,72 @@
+begin 644 test_pax_xattr_header_schily.tar
+M4&%X2&5A9&5R+V9I;&4`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#<U-2``,#`P,#`P(``P,#`P,#`@`#`P,#`P,#`P,3<V
+M(#`P,#`P,#`P,#`U(#`Q,C`Q-``@>```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,```````
+M````````````````````````````````````````````````````````````
+M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````R,"!C=&EM93TT+C`P,#`P,#`T"C(P(&%T:6UE
+M/3(N,#`P,#`P,#(*,C`@;71I;64]-2XP,#`P,#`P-0HS,2!30TA)3%DN>&%T
+M='(N=7-E<BYD871A,CU865H*,S4@4T-(24Q9+GAA='1R+G5S97(N9&%T83$]
+M04)#1$5&1PH`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&9I;&4`````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````````````````````````````P
+M,#`W-34@`#`P,#`P,"``,#`P,#`P(``P,#`P,#`P,#`Q,"`P,#`P,#`P,#`P
+M-2`P,3`P,C8`(#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(`,#``````````````````````
+M````````````````````````````````````````````````````````````
+M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````,3(S-#4V-S@`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+,````````````````
+`
+end
diff --git a/libarchive/test/test_read_disk_directory_traversals.c b/libarchive/test/test_read_disk_directory_traversals.c
index 7dd19157d4d2..bbfe91ab8e5e 100644
--- a/libarchive/test/test_read_disk_directory_traversals.c
+++ b/libarchive/test/test_read_disk_directory_traversals.c
@@ -1775,7 +1775,8 @@ test_parent(void)
archive_entry_clear(ae);
r = archive_read_next_header2(a, ae);
if (r == ARCHIVE_FAILED) {
-#if defined(O_PATH) || defined(O_SEARCH) || defined(O_EXEC)
+#if defined(O_PATH) || defined(O_SEARCH) || \
+ (defined(__FreeBSD__) && defined(O_EXEC))
assertEqualIntA(a, ARCHIVE_OK, r);
#endif
/* Close the disk object. */
diff --git a/libarchive/test/test_read_format_7zip_packinfo_digests.7z.uu b/libarchive/test/test_read_format_7zip_packinfo_digests.7z.uu
new file mode 100644
index 000000000000..4c216170a8e2
--- /dev/null
+++ b/libarchive/test/test_read_format_7zip_packinfo_digests.7z.uu
@@ -0,0 +1,7 @@
+begin 644 test_read_format_7zip_packinfo_digests.7z
+M-WJ\KR<<``*^Y_3?$`````````!E`````````&/C(9T!``-A86$*``$``V)B
+M8@H``00&``()"`@*`5\J+KLX07WL``<+`@`!(2$!%@$A(0$6#`0$"@&57?AW
+MX1\F3``(```%`A$9`&$`+@!T`'@`=````&(`+@!T`'@`=````!02`0"`FYCT
+.W+;5`8";F/3<MM4!````
+`
+end
diff --git a/libarchive/test/test_read_format_7zip_packinfo_digests.c b/libarchive/test/test_read_format_7zip_packinfo_digests.c
new file mode 100644
index 000000000000..94cd1ad32e42
--- /dev/null
+++ b/libarchive/test/test_read_format_7zip_packinfo_digests.c
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 2019 Martin Matuska
+ * 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"
+__FBSDID("$FreeBSD");
+
+/* Read archive with digests in PackInfo */
+DEFINE_TEST(test_read_format_7zip_packinfo_digests)
+{
+ struct archive_entry *ae;
+ struct archive *a;
+ char buff[4];
+ const char *refname = "test_read_format_7zip_packinfo_digests.7z";
+
+ 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));
+
+ /* Verify regular file1. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt((AE_IFREG | 0666), archive_entry_mode(ae));
+ assertEqualString("a.txt", archive_entry_pathname(ae));
+ assertEqualInt(1576808819, archive_entry_mtime(ae));
+ assertEqualInt(4, archive_entry_size(ae));
+ assertEqualInt(archive_entry_is_encrypted(ae), 0);
+ assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
+ assertEqualInt(4, archive_read_data(a, buff, sizeof(buff)));
+ assertEqualMem(buff, "aaa\n", 4);
+
+ /* Verify regular file2. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt((AE_IFREG | 0666), archive_entry_mode(ae));
+ assertEqualString("b.txt", archive_entry_pathname(ae));
+ assertEqualInt(1576808819, archive_entry_mtime(ae));
+ assertEqualInt(4, archive_entry_size(ae));
+ assertEqualInt(archive_entry_is_encrypted(ae), 0);
+ assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
+ assertEqualInt(4, archive_read_data(a, buff, sizeof(buff)));
+ assertEqualMem(buff, "bbb\n", 4);
+
+ assertEqualInt(2, archive_file_count(a));
+
+ /* End of archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify archive format. */
+ assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
+ assertEqualIntA(a, ARCHIVE_FORMAT_7ZIP, archive_format(a));
+
+ /* Close the archive. */
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/libarchive/test/test_read_format_lha_filename_utf16.c b/libarchive/test/test_read_format_lha_filename_utf16.c
new file mode 100644
index 000000000000..7ab13e43bdd3
--- /dev/null
+++ b/libarchive/test/test_read_format_lha_filename_utf16.c
@@ -0,0 +1,143 @@
+/*-
+ * Copyright (c) 2019 Martin Matuska
+ * 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"
+__FBSDID("$FreeBSD");
+
+#include <locale.h>
+
+static void
+test_read_format_lha_filename_UTF16_UTF8(const char *refname)
+{
+ struct archive *a;
+ struct archive_entry *ae;
+
+ /*
+ * Read LHA filename in en_US.UTF-8.
+ */
+ if (NULL == setlocale(LC_ALL, "en_US.UTF-8")) {
+ skipping("en_US.UTF-8 locale not available on this system.");
+ return;
+ }
+ /*
+ * Create a read object only for a test that platform support
+ * a character-set conversion because we can read a character-set
+ * of filenames from the header of an lha archive file and so we
+ * want to test that it works well.
+ */
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ if (ARCHIVE_OK != archive_read_set_options(a, "hdrcharset=CP932")) {
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+ skipping("This system cannot convert character-set"
+ " from CP932 to UTF-8.");
+ return;
+ }
+ if (ARCHIVE_OK != archive_read_set_options(a, "hdrcharset=UTF-16")) {
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+ skipping("This system cannot convert character-set"
+ " from UTF-16 to UTF-8.");
+ return;
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+ 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));
+
+ /* Note that usual Japanese filenames are tested in other cases */
+#if defined(__APPLE__)
+ /* NFD normalization */
+ /* U:O:A:u:o:a: */
+ #define UMLAUT_DIRNAME "\x55\xcc\x88\x4f\xcc\x88\x41\xcc\x88\x75\xcc\x88\x6f"\
+ "\xcc\x88\x61\xcc\x88/"
+ /* a:o:u:A:O:U:.txt */
+ #define UMLAUT_FNAME "\x61\xcc\x88\x6f\xcc\x88\x75\xcc\x88\x41\xcc\x88"\
+ "\x4f\xcc\x88\x55\xcc\x88.txt"
+#else
+ /* NFC normalization */
+ /* U:O:A:u:o:a: */
+ #define UMLAUT_DIRNAME "\xc3\x9c\xc3\x96\xc3\x84\xc3\xbc\xc3\xb6\xc3\xa4/"
+ /* a:o:u:A:O:U:.txt */
+ #define UMLAUT_FNAME "\xc3\xa4\xc3\xb6\xc3\xbc\xc3\x84\xc3\x96\xc3\x9c.txt"
+#endif
+
+/* "Test" in Japanese Katakana */
+#define KATAKANA_FNAME "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt"
+#define KATAKANA_DIRNAME "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88/"
+
+ /* Verify regular file. U:O:A:u:o:a:/a:o:u:A:O:U:.txt */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(UMLAUT_DIRNAME UMLAUT_FNAME, archive_entry_pathname(ae));
+ assertEqualInt(12, archive_entry_size(ae));
+
+ /* Verify directory. U:O:A:u:o:a:/ */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(UMLAUT_DIRNAME, archive_entry_pathname(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+
+ /* Verify regular file. U:O:A:u:o:a:/("Test" in Japanese).txt */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(UMLAUT_DIRNAME KATAKANA_FNAME,
+ archive_entry_pathname(ae));
+ assertEqualInt(25, archive_entry_size(ae));
+
+ /* Verify regular file. ("Test" in Japanese)/a:o:u:A:O:U:.txt */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(KATAKANA_DIRNAME UMLAUT_FNAME,
+ archive_entry_pathname(ae));
+ assertEqualInt(12, archive_entry_size(ae));
+
+ /* Verify directory. ("Test" in Japanese)/ */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(KATAKANA_DIRNAME, archive_entry_pathname(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+
+ /* Verify regular file. a:o:u:A:O:U:.txt */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(UMLAUT_FNAME, archive_entry_pathname(ae));
+ assertEqualInt(12, archive_entry_size(ae));
+
+ /* End of archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify archive format. */
+ assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
+ assertEqualIntA(a, ARCHIVE_FORMAT_LHA, archive_format(a));
+
+ /* Close the archive. */
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
+DEFINE_TEST(test_read_format_lha_filename_UTF16)
+{
+ /* A sample file was created with Unlha32.dll. */
+ const char *refname = "test_read_format_lha_filename_utf16.lzh";
+ extract_reference_file(refname);
+
+ test_read_format_lha_filename_UTF16_UTF8(refname);
+}
+
diff --git a/libarchive/test/test_read_format_lha_filename_utf16.lzh.uu b/libarchive/test/test_read_format_lha_filename_utf16.lzh.uu
new file mode 100644
index 000000000000..ca5da7a64e59
--- /dev/null
+++ b/libarchive/test/test_read_format_lha_filename_utf16.lzh.uu
@@ -0,0 +1,19 @@
+begin 644 test_read_format_lha_filename_utf16.lzh
+M@0`M;&@P+0P````,````L/5872`"IW%-!P!&I`,```T``5]?7U]?7RYT>'0*
+M``)?7U]?7U__%P!$Y`#V`/P`Q`#6`-P`+@!T`'@`=``1`$7<`-8`Q`#\`/8`
+MY`#__QL`078S<F.15=4!]0V8@I%5U0'U#9B"D575`08```\:!P``PZ3#ML.\
+MPX3#EL.<90`M;&AD+0``````````PX"D72`"``!-!P!&I`,```,``0H``E]?
+M7U]?7_\%`$`0`!$`1=P`U@#$`/P`]@#D`/__&P!!FDHB>9B"U0$H^DQ_F(+5
+M`2CZ3'^8@M4!!@``GW<'``!J`"UL:#`M&0```!D```!V)L1=(`*CNTT'`$:D
+M`P``#0`!@V6#6(-G+G1X=`H``E]?7U]?7_\1`$7<`-8`Q`#\`/8`Y`#__QL`
+M00IF#4J@E-4!L"5C?'65U0&P)6-\=975`08``$%^!P``5&5S="!I;B!*87!A
+M;F5S92!+871A:V%N87L`+6QH,"T,````#````+#U6%T@`J=Q30<`1J0#```-
+M``%?7U]?7U\N='AT"@`"@V6#6(-G_Q<`1.0`]@#\`,0`U@#<`"X`=`!X`'0`
+M"P!%QC"Y,,@P__\;`$'D5O!-H)35`?4-F(*15=4!Y%;P3:"4U0$&``"A+0<`
+M`,.DP[;#O,.$PY;#G%0`+6QH9"T``````````-3`PET@`@``30<`1J0#```#
+M``$*``*#98-8@V?_!0!`$``;`$%%!\Y.H)35`3/_]%&@E-4!,__T4:"4U0$&
+M``!>;@<``&8`+6QH,"T,````#````+#U6%T@`J=Q30<`1J0#```-``%?7U]?
+M7U\N='AT%P!$Y`#V`/P`Q`#6`-P`+@!T`'@`=``;`$'D5O!-H)35`?4-F(*1
+@5=4!Y%;P3:"4U0$&``"M>`<``,.DP[;#O,.$PY;#G`#D
+`
+end
diff --git a/libarchive/test/test_read_format_rar5.c b/libarchive/test/test_read_format_rar5.c
index b4ef29e464bf..bb94d4e34e25 100644
--- a/libarchive/test/test_read_format_rar5.c
+++ b/libarchive/test/test_read_format_rar5.c
@@ -969,13 +969,12 @@ DEFINE_TEST(test_read_format_rar5_readtables_overflow)
PROLOGUE("test_read_format_rar5_readtables_overflow.rar");
- assertA(0 == archive_read_next_header(a, &ae));
/* This archive is invalid. However, processing it shouldn't cause any
* buffer overflow errors during reading rar5 tables. */
- assertA(archive_read_data(a, buf, sizeof(buf)) <= 0);
- /* This test only cares about not returning success here. */
- assertA(ARCHIVE_OK != archive_read_next_header(a, &ae));
+ (void) archive_read_next_header(a, &ae);
+ (void) archive_read_data(a, buf, sizeof(buf));
+ (void) archive_read_next_header(a, &ae);
EPILOGUE();
}
@@ -986,13 +985,12 @@ DEFINE_TEST(test_read_format_rar5_leftshift1)
PROLOGUE("test_read_format_rar5_leftshift1.rar");
- assertA(0 == archive_read_next_header(a, &ae));
/* This archive is invalid. However, processing it shouldn't cause any
* errors related to undefined operations when using -fsanitize. */
- assertA(archive_read_data(a, buf, sizeof(buf)) <= 0);
- /* This test only cares about not returning success here. */
- assertA(ARCHIVE_OK != archive_read_next_header(a, &ae));
+ (void) archive_read_next_header(a, &ae);
+ (void) archive_read_data(a, buf, sizeof(buf));
+ (void) archive_read_next_header(a, &ae);
EPILOGUE();
}
@@ -1003,14 +1001,12 @@ DEFINE_TEST(test_read_format_rar5_leftshift2)
PROLOGUE("test_read_format_rar5_leftshift2.rar");
- assertA(0 == archive_read_next_header(a, &ae));
-
/* This archive is invalid. However, processing it shouldn't cause any
* errors related to undefined operations when using -fsanitize. */
- assertA(archive_read_data(a, buf, sizeof(buf)) <= 0);
- /* This test only cares about not returning success here. */
- assertA(ARCHIVE_OK != archive_read_next_header(a, &ae));
+ (void) archive_read_next_header(a, &ae);
+ (void) archive_read_data(a, buf, sizeof(buf));
+ (void) archive_read_next_header(a, &ae);
EPILOGUE();
}
@@ -1021,14 +1017,12 @@ DEFINE_TEST(test_read_format_rar5_truncated_huff)
PROLOGUE("test_read_format_rar5_truncated_huff.rar");
- assertA(0 == archive_read_next_header(a, &ae));
-
/* This archive is invalid. However, processing it shouldn't cause any
* errors related to undefined operations when using -fsanitize. */
- assertA(archive_read_data(a, buf, sizeof(buf)) <= 0);
- /* This test only cares about not returning success here. */
- assertA(ARCHIVE_OK != archive_read_next_header(a, &ae));
+ (void) archive_read_next_header(a, &ae);
+ (void) archive_read_data(a, buf, sizeof(buf));
+ (void) archive_read_next_header(a, &ae);
EPILOGUE();
}
@@ -1058,14 +1052,12 @@ DEFINE_TEST(test_read_format_rar5_distance_overflow)
PROLOGUE("test_read_format_rar5_distance_overflow.rar");
- assertA(0 == archive_read_next_header(a, &ae));
-
/* This archive is invalid. However, processing it shouldn't cause any
* errors related to variable overflows when using -fsanitize. */
- assertA(archive_read_data(a, buf, sizeof(buf)) <= 0);
- /* This test only cares about not returning success here. */
- assertA(ARCHIVE_OK != archive_read_next_header(a, &ae));
+ (void) archive_read_next_header(a, &ae);
+ (void) archive_read_data(a, buf, sizeof(buf));
+ (void) archive_read_next_header(a, &ae);
EPILOGUE();
}
@@ -1076,14 +1068,12 @@ DEFINE_TEST(test_read_format_rar5_nonempty_dir_stream)
PROLOGUE("test_read_format_rar5_nonempty_dir_stream.rar");
- assertA(0 == archive_read_next_header(a, &ae));
-
/* This archive is invalid. However, processing it shouldn't cause any
* errors related to buffer overflows when using -fsanitize. */
- assertA(archive_read_data(a, buf, sizeof(buf)) <= 0);
- /* This test only cares about not returning success here. */
- assertA(ARCHIVE_OK != archive_read_next_header(a, &ae));
+ (void) archive_read_next_header(a, &ae);
+ (void) archive_read_data(a, buf, sizeof(buf));
+ (void) archive_read_next_header(a, &ae);
EPILOGUE();
}
@@ -1205,13 +1195,13 @@ DEFINE_TEST(test_read_format_rar5_different_window_size)
* errors during processing. */
(void) archive_read_next_header(a, &ae);
- while(0 != archive_read_data(a, buf, sizeof(buf))) {}
+ while(0 < archive_read_data(a, buf, sizeof(buf))) {}
(void) archive_read_next_header(a, &ae);
- while(0 != archive_read_data(a, buf, sizeof(buf))) {}
+ while(0 < archive_read_data(a, buf, sizeof(buf))) {}
(void) archive_read_next_header(a, &ae);
- while(0 != archive_read_data(a, buf, sizeof(buf))) {}
+ while(0 < archive_read_data(a, buf, sizeof(buf))) {}
EPILOGUE();
}
@@ -1226,7 +1216,43 @@ DEFINE_TEST(test_read_format_rar5_arm_filter_on_window_boundary)
* errors during processing. */
(void) archive_read_next_header(a, &ae);
- while(0 != archive_read_data(a, buf, sizeof(buf))) {}
+ while(0 < archive_read_data(a, buf, sizeof(buf))) {}
+
+ EPILOGUE();
+}
+
+DEFINE_TEST(test_read_format_rar5_different_solid_window_size)
+{
+ char buf[4096];
+ PROLOGUE("test_read_format_rar5_different_solid_window_size.rar");
+
+ /* Return codes of those calls are ignored, because this sample file
+ * is invalid. However, the unpacker shouldn't produce any SIGSEGV
+ * errors during processing. */
+
+ (void) archive_read_next_header(a, &ae);
+ while(0 < archive_read_data(a, buf, sizeof(buf))) {}
+
+ (void) archive_read_next_header(a, &ae);
+ while(0 < archive_read_data(a, buf, sizeof(buf))) {}
+
+ (void) archive_read_next_header(a, &ae);
+ while(0 < archive_read_data(a, buf, sizeof(buf))) {}
+
+ EPILOGUE();
+}
+
+DEFINE_TEST(test_read_format_rar5_different_winsize_on_merge)
+{
+ char buf[4096];
+ PROLOGUE("test_read_format_rar5_different_winsize_on_merge.rar");
+
+ /* Return codes of those calls are ignored, because this sample file
+ * is invalid. However, the unpacker shouldn't produce any SIGSEGV
+ * errors during processing. */
+
+ (void) archive_read_next_header(a, &ae);
+ while(0 < archive_read_data(a, buf, sizeof(buf))) {}
EPILOGUE();
}
diff --git a/libarchive/test/test_read_format_rar5_different_solid_window_size.rar.uu b/libarchive/test/test_read_format_rar5_different_solid_window_size.rar.uu
new file mode 100644
index 000000000000..b131e6f00c8e
--- /dev/null
+++ b/libarchive/test/test_read_format_rar5_different_solid_window_size.rar.uu
@@ -0,0 +1,73 @@
+begin 644 test_read_format_rar5_different_solid_window_size.rar
+M4F%R(1H'`0"-[P+2``'#M#P\7P$'`0"-[P+2``7#````1H68F`#___\`````
+M```0^OKZ^OJ%F)B8F)A)`)@"F-(%87)4`,.T/#Q?`0<!`(WO`M(`4F%R(1H'
+M`0"-[P+2``+'#PD`<@$A!QH:(](M``$:(](M``(:!P$`C>\"T@`"QP\`"7(A
+MFC$!$AHCTBT``B@A4F%2(1H'&.D````!`(WO`M(`!<-%````1A?'#P`)<B$:
+M!P$:T@7"F!=A_________P$$____,/__F!=A)F%R*%)8(W=T4F%R(1H'`0"-
+M[P+2``+'#PD`<@$A!QH:(](M``$:(](M``(:!P$`C>\"T@`"QP\`"7(AFC$!
+M$AHCTBT``B@A4F%2(1H'&.D````!`(WO`M(`!<-%````1A?'#P`)<B$:!P$:
+MT@7"F!=A_________P$$____,/__F!=A)B8(<@IE`.\*"7(`````````````
+M=O____________________\`!<-%````1A?'#_\P__\$(DT89%`(`0(`@$U3
+M0T8`````Y!]W__\;-A8T``````"!`$#U`@`!`&@````!]9^?```5`"T-````
+M`6QT(%P*"75I9%P*"75I9%P*"75I9%P*"75I9%P*"75I9%P*"7456BUL:#4M
+M#0````%L<0!SI/\````!]9^?```5`"T-`````6P56BUL:#4M#0````%L<0!S
+MI/\````!]9^?```5`"T-``#_``#J`"L-"E=!`````````````````````!$`
+M`!04%!04%!06`O__%*"@H*"@H*"@_PIW\M$"+@L*+@I&"@HV"BX*"BXH"F0*
+M+@H*+@HNYWJ""BX*"C?^___L+H`NCPHNMX*"@H*"@H*"@H*"@H*"@H*"@H*"
+M@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"
+M"@HV"BX*"BXH"F0*+@H*+@HNYWJ""BX*"C?^___L+H`N"BZW"F?_&_9<9```
+M@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"`/\G`)$`
+M@`#L`!OV7&0```%L%5HM;&@U+0T````!;'$`<Z3_`````71Y<&4];`HN"BX*
+M+@HN"BX*+FIJ:FIJ:@HN,#@T279R(&1E=FEC93US=B]S964];`HN"BX*+G0@
+M9'!Y93UL"BX*+@HN"BX*+@HN:FIJ:E)#)R\V,#@U+W-E="!\>7!E/6P*+@HN
+M"BYT('1Y<&4];`HN,"X*+@HN="!T>7!E/2X*+@HN"BYJ:FHP+W-E93UL"BX*
+M+@HN="!T>7!E+W-E="!T>7!E/6P*+@HN"BYT+G0@='G^6_]P9</#P\/#P\/#
+MP\/#P\/#P\/#P\/#P\/"P\/#P\/#+W-E="!D979I8V4]8G-D<V5T(&1E=FEC
+M93UB<V1O<RPM9"PN9"PN"BX*<R=D+2PL+F0L+@HN"B=S+"UD+"X*+@HN"BX*
+M+@HN"BL*70I="ET*70I="ET*70I="ET*70I="ET*70I="ET*70I="ET*70I=
+M"B%="ET*70I="ET*70I="ET*70I="ET*70I="@I="ET*70I="ET*70I="ET*
+M70I="ET*70I="ET*70I="ET*70I="ET*70H*70I="ET*70I="ET*70I="ET*
+M70I="ET*70I="ET*70I="ET*70I="ET*70I="ET*70I="ET*70I="ET*70I=
+M"ET*70I="ET*75T*70I="ET*70I="ET*9"PN"BX*+@HN"BX*"BX*+BYS9&7_
+M]P```````,/#P\/#P\/#P\/#P\/#P\/#P\/#P\/#P\,``"D(-```!0`!``$`
+M@A8!!0`````````````````!```(\/#P\/!A\/#P\/#P\.+P\/#P\/#P,O#P
+M\%!+`P1.`%IB#B@!`/P```#M@!4```###P\/#V?QZ@\/#P\/#P\/#P\/#P\/
+M#P\/#P\/#P\/#P\/#P\/#U37[OL```!02R&PHU:*0,/#)\+#S</#0\/#PP\`
+M#P\!]9^?```5`"T-`````6P56BUL:#4M#0````%L<0!SI/\````!]9^?```5
+M`"T-`````6P56BUL:#4M#0````%L<0!SI/\````!]9^?```5`"T-`````6P5
+M6BUL:#4M#0````%L<0!SI/\````!]9^?```5`"T-`````6P56BUL:#4M#0``
+M``%L<0!SI/\````!]9^?```%`"T-`````8Z.CHXICHZ.K0'H````````````
+M`````/]L%5HM;&@U+0T````!;'$`<Z3_`````?6?GP``%0`M#0````%L%5HM
+M;&@U+0T````!;'$`<Z3_`````?6?GP``%0`M#0````%L%5HM;&@U+0T`````
+M;'$`<Z3_`````?6?GP``%0`M#0````%L%5HM;&@U+=(``0!R(8WO`M(`M`%?
+MC>\"T@`"TGX!M,-'4CQ2:7`)20`&`````````(WO`M(``0!R(8WO`M(``0!R
+M(8WO`M(``0!R(8WO`M(`M`%?C>\"T@`"TGX!M,-'4CQ:!@!I`'`)20``````
+M`(WO`M(``0!R(8WO`M(``0!R(8WO`M(``0!R(8WO`M(`M`%?C>^NT@`"TGX!
+MM%)A<B$:!P$`C>\"T@`"PP<<@`<`_O__T?___^@@JP#_Q00``B$<`0(`#@``
+M`0``_@C2(`$>____"```_?__$`#_W5A04)#_!&R&;;%DS,RWL0!)`(/__P#_
+M`/\`^?__\&3/)#)(L0!)`#J#+O_______REH%PHHV#!="0"N)$%SF_J;$___
+M_YP#%9,I````_________Q/_____________________________________
+M_RC_____`P````````#_____*/]!04%!0=U891/_9?]0/2[_______\I:!<*
+M*-@P70D`KB1!<YOZFQ/___^<_^5L*0```/________\3________________
+M______________________\H____/0T.#0I5"E!!W5AE$_]E_U`]/0T.#0I5
+M"E#;V^+;V]O;V____________W________________________________W_
+ME/\56BUL:#4M#0````%L<0!SI/\````!]9^?```5`"T-`````6P56BUL:#4M
+M#0````%L<0!SI/\````!]9^?```5`"T-`````6P56BUL:#4M#0````%L<0!S
+MI/\````!]9^?```5`"T-`````6P56BUL:#4M#0````%L<0!SI/\````!]9^?
+M```5`"T-`````6P56BUL:#4M#0````%L<0!SI/\````!]9^?```5`"T-````
+M`6P56BUL:#4M#0````%L<0!SI/\````!]9^?```5`"T-`````6P56BUL:#4M
+M#0````%L<0!SI/\````!]9^?8C,*-`HN"EQ<7%Q<7%Q<7%Q<7%Q<7%Q<7%Q<
+M7`3_________`F@`!+_)_P\LL`#__V%R(1H'``1G=$Q24``0````(`$`````
+M```,J7\`+@TU'`#]_P`!````````!EQ<8C<*-`HN"EQ<7%Q<7%Q<7%Q<7%Q<
+M7%Q<7%Q<7`3__RTQ#0I#;U!+`P31!-'1!-$$*%+KZB$6____[```````````
+M-WJ\KR<<\9WSM=;L```````````V``````#___^"@H(!!0("`@("`@("`@("
+M`@(/#P\/#P\/#P\/#U0ZS<@`_\/_/\/#P\/#P\/#P\/#P\/#P\/#P\/#P\/#
+MP\/#P\/#P\/#P\/#P\/#P\/#P\/#P\/#P\/#P\/'P\/#PT```(F?GY_RGP&?
+MWY^?]4```(F?GY_RGP&?WY^?]4```(DO<V5T(&9L86=S/0HN"BX*+@HN"BX*
+M+@HN"BXN"BX*+@HN"BX*+@HN"BX*"BX*+@HN"BX*)@HN"BX*+@HN"BX*+@HN
+M"BX*+@HN"BX*+@HN"BX*+@HN"BX*+@HN"BX*+@`*+@HN"BY^+@HN"BX*+@HN
+M"BX*+@HN"@HN"BX*+@HN"BX*+@HN"BX*+@HA&@<`!&=T3%)0`!`````@4$L#
+M!#$`</^I?P`N#34<`/W_``$7%@I<7"Y<7%RT`5^-[P+2```$O\FTPT=2/%II
+9<`E)``8`````````C>\"T@``````````````
+`
+end
diff --git a/libarchive/test/test_read_format_rar5_different_winsize_on_merge.rar.uu b/libarchive/test/test_read_format_rar5_different_winsize_on_merge.rar.uu
new file mode 100644
index 000000000000..85391fa4e1f6
--- /dev/null
+++ b/libarchive/test/test_read_format_rar5_different_winsize_on_merge.rar.uu
@@ -0,0 +1,16 @@
+begin 644 test_read_format_rar5_different_winsize_on_merge.rar.uu
+M4F%R(1H'`0"-[P+2``+''QP,!`H``"0`N)$#`0(H$"<"``X`/3Q/`0"V````
+MQ@$````V`/^%02`H^B7&,NX``"F&AK%M-50O<WY2!P$`C>\"T@`"_[6U,1"U
+MM;6UM[BU45)A<K6UM;6UM+6U```\______?______________P`&80"-[P+2
+MT@`#TA________\`M,-:!`8``(0A_^\"TE)A<J$?Y@<!`(WO`BCZ)<8R[@``
+M*8:&L6TU5"]S?E('`0"-[P+2``+_M0`````````DM3$0M;6UM;>XM5%287*U
+MM;6UM;2UM0``//_____W______________\`!F$`C>\"TM(``](?________
+M`+3#6@0&D0,!`B@0)P(`#@`]/$\!`+8```#&`0```#8`_X5!("CZ)<8R[@``
+M*8:&L6TU5"]S?E(`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````<!`(WO````
+M`````````````````````````````````````````````````````$``````
+M`````````````````````````````````#$S-S4V-#<`_P0$!`0G!`0$!`0$
+"!`0`
+`
+end
diff --git a/libarchive/test/test_sparse_basic.c b/libarchive/test/test_sparse_basic.c
index f12b6af4862a..5ad591be830d 100644
--- a/libarchive/test/test_sparse_basic.c
+++ b/libarchive/test/test_sparse_basic.c
@@ -127,7 +127,7 @@ create_sparse_file(const char *path, const struct sparse *s)
assert(DeviceIoControl(handle, FSCTL_SET_SPARSE, NULL, 0,
NULL, 0, &dmy, NULL) != 0);
- size_t offsetSoFar = 0;
+ uint64_t offsetSoFar = 0;
while (s->type != END) {
if (s->type == HOLE) {
@@ -282,7 +282,7 @@ create_sparse_file(const char *path, const struct sparse *s)
{
char buff[1024];
int fd;
- size_t total_size = 0;
+ uint64_t total_size = 0;
const struct sparse *cur = s;
memset(buff, ' ', sizeof(buff));
@@ -555,6 +555,12 @@ DEFINE_TEST(test_sparse_basic)
{ HOLE, 1 }, { DATA, 10240 },
{ END, 0 }
};
+ const struct sparse sparse_file4[] = {
+ { DATA, 4096 }, { HOLE, 0xc0000000 },
+ /* This hole overflows the offset if stored in 32 bits. */
+ { DATA, 4096 }, { HOLE, 0x50000000 },
+ { END, 0 }
+ };
/*
* Test for the case that sparse data indicates just the whole file
@@ -596,6 +602,7 @@ DEFINE_TEST(test_sparse_basic)
verify_sparse_file(a, "file2", sparse_file2, 20);
/* Encoded non sparse; expect a data block but no sparse entries. */
verify_sparse_file(a, "file3", sparse_file3, 0);
+ verify_sparse_file(a, "file4", sparse_file4, 2);
assertEqualInt(ARCHIVE_OK, archive_read_free(a));