Vendor changes (relevant to FreeBSD): - bugfixes, improvemens and optimizations in ACL code - NFSv4 ACLs can now be extracted from Solaris tar archives Security fixes: - cab reader: endless loop when parsing MSZIP signature (OSS-Fuzz 335) - LHA reader: heap-buffer-overflow in lha_read_file_header_1() (CVE-2017-5601) - LZ4 reader: null-pointer dereference in lz4_filter_read_legacy_stream() (OSS-Fuzz 453) - mtree reader: heap-buffer-overflow in detect_form() (OSS-Fuzz 421, 443) - WARC reader: heap-buffer-overflow in xstrpisotime() (OSS-Fuzz 382, 458) Memory leak fixes: - ACL support: free memory allocated by acl_get_qualifier() - disk writer: missing free in create_filesystem_object() - file reader: fd leak (Coverity 1016755) - gnutar writer: fix free in archive_write_gnutar_header() (Coverity 1016752) - iso 9660 reader: missing free in parse_file_info() (part. Coverity 1016754) - program reader: missing free in __archive_read_program() - program writer: missing free in __archive_write_program_free() - xar reader: missing free in xar_cleanup() - xar reader: missing frees in expat_xmlattr_setup() (Coverity 1229979-1229981) - xar writer: missing free in file_free() - zip reader: missing free in zip_read_locazip_read_local_file_header()
88 lines
3.6 KiB
C
88 lines
3.6 KiB
C
/*-
|
|
* Copyright (c) 2003,2014 Tim Kientzle
|
|
* 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$");
|
|
|
|
DEFINE_TEST(test_read_format_zip_nested)
|
|
{
|
|
const char *refname = "test_read_format_zip_nested.zip";
|
|
char *p, *inner;
|
|
size_t s, innerLength;
|
|
struct archive *a;
|
|
struct archive_entry *ae;
|
|
|
|
extract_reference_file(refname);
|
|
p = slurpfile(&s, refname);
|
|
|
|
/* Inspect outer Zip */
|
|
assert((a = archive_read_new()) != NULL);
|
|
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
|
|
assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, s, 1));
|
|
|
|
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
|
|
assertEqualString("small.zip", archive_entry_pathname(ae));
|
|
assertEqualInt(211, archive_entry_size(ae));
|
|
assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
|
|
assertEqualInt(archive_entry_is_encrypted(ae), 0);
|
|
assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
|
|
|
|
/* Save contents of inner Zip. */
|
|
innerLength = (size_t)archive_entry_size(ae);
|
|
inner = calloc(innerLength, 1);
|
|
assertEqualInt(innerLength, archive_read_data(a, inner, innerLength));
|
|
|
|
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
|
|
assertEqualString("file.txt", archive_entry_pathname(ae));
|
|
assertEqualInt(53, archive_entry_size(ae));
|
|
assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
|
|
assertEqualInt(archive_entry_is_encrypted(ae), 0);
|
|
assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
|
|
|
|
/* Close outer Zip */
|
|
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
|
|
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
|
|
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
|
|
|
|
free(p);
|
|
|
|
/* Inspect inner Zip. */
|
|
assert((a = archive_read_new()) != NULL);
|
|
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
|
|
assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, inner, innerLength, 1));
|
|
|
|
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
|
|
assertEqualString("another_file.txt", archive_entry_pathname(ae));
|
|
assertEqualInt(29, archive_entry_size(ae));
|
|
assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
|
|
assertEqualInt(archive_entry_is_encrypted(ae), 0);
|
|
assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
|
|
|
|
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
|
|
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
|
|
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
|
|
|
|
free(inner);
|
|
}
|