Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Oct 2017 20:54:53 +0000 (UTC)
From:      Martin Matuska <mm@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r324417 - in stable/11: contrib/libarchive/cat/test contrib/libarchive/cpio contrib/libarchive/cpio/test contrib/libarchive/libarchive contrib/libarchive/libarchive/test contrib/libarch...
Message-ID:  <201710082054.v98Ksr4N079065@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mm
Date: Sun Oct  8 20:54:53 2017
New Revision: 324417
URL: https://svnweb.freebsd.org/changeset/base/324417

Log:
  MFH r324148:
  Sync libarchive with vendor.
  
  Relevant vendor changes:
    PR #905: Support for Zstandard read and write filters
    PR #922: Avoid overflow when reading corrupt cpio archive
    Issue #935: heap-based buffer overflow in xml_data (CVE-2017-14166)
    OSS-Fuzz 2936: Place a limit on the mtree line length
    OSS-Fuzz 2394: Ensure that the ZIP AES extension header is large enough
    OSS-Fuzz 573: Read off-by-one error in RAR archives (CVE-2017-14502)
  
  Security:	CVE-2017-14166, CVE-2017-14502

Added:
  stable/11/contrib/libarchive/cat/test/test_empty.zst.uu
     - copied unchanged from r324148, head/contrib/libarchive/cat/test/test_empty.zst.uu
  stable/11/contrib/libarchive/cat/test/test_empty_zstd.c
     - copied unchanged from r324148, head/contrib/libarchive/cat/test/test_empty_zstd.c
  stable/11/contrib/libarchive/cat/test/test_expand.zst.uu
     - copied unchanged from r324148, head/contrib/libarchive/cat/test/test_expand.zst.uu
  stable/11/contrib/libarchive/cat/test/test_expand_zstd.c
     - copied unchanged from r324148, head/contrib/libarchive/cat/test/test_expand_zstd.c
  stable/11/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu
     - copied unchanged from r324148, head/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu
  stable/11/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c
     - copied unchanged from r324148, head/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c
  stable/11/contrib/libarchive/cpio/test/test_option_zstd.c
     - copied unchanged from r324148, head/contrib/libarchive/cpio/test/test_option_zstd.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c
     - copied unchanged from r324148, head/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c
  stable/11/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c
     - copied unchanged from r324148, head/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c
  stable/11/contrib/libarchive/libarchive/test/test_compat_zstd.c
     - copied unchanged from r324148, head/contrib/libarchive/libarchive/test/test_compat_zstd.c
  stable/11/contrib/libarchive/libarchive/test/test_compat_zstd_1.tar.zst.uu
     - copied unchanged from r324148, head/contrib/libarchive/libarchive/test/test_compat_zstd_1.tar.zst.uu
  stable/11/contrib/libarchive/libarchive/test/test_write_filter_zstd.c
     - copied unchanged from r324148, head/contrib/libarchive/libarchive/test/test_write_filter_zstd.c
  stable/11/contrib/libarchive/tar/test/test_extract.tar.zst.uu
     - copied unchanged from r324148, head/contrib/libarchive/tar/test/test_extract.tar.zst.uu
  stable/11/contrib/libarchive/tar/test/test_extract_tar_zstd.c
     - copied unchanged from r324148, head/contrib/libarchive/tar/test/test_extract_tar_zstd.c
  stable/11/contrib/libarchive/tar/test/test_option_zstd.c
     - copied unchanged from r324148, head/contrib/libarchive/tar/test/test_option_zstd.c
Modified:
  stable/11/contrib/libarchive/cpio/bsdcpio.1
  stable/11/contrib/libarchive/cpio/cmdline.c
  stable/11/contrib/libarchive/cpio/cpio.c
  stable/11/contrib/libarchive/cpio/cpio.h
  stable/11/contrib/libarchive/libarchive/archive.h
  stable/11/contrib/libarchive/libarchive/archive_cmdline.c
  stable/11/contrib/libarchive/libarchive/archive_platform.h
  stable/11/contrib/libarchive/libarchive/archive_read_append_filter.c
  stable/11/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
  stable/11/contrib/libarchive/libarchive/archive_read_filter.3
  stable/11/contrib/libarchive/libarchive/archive_read_support_filter_all.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_format_cpio.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_format_rar.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_format_tar.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_format_xar.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_format_zip.c
  stable/11/contrib/libarchive/libarchive/archive_string.c
  stable/11/contrib/libarchive/libarchive/archive_version_details.c
  stable/11/contrib/libarchive/libarchive/archive_write.3
  stable/11/contrib/libarchive/libarchive/archive_write_add_filter.c
  stable/11/contrib/libarchive/libarchive/archive_write_add_filter_by_name.c
  stable/11/contrib/libarchive/libarchive/archive_write_filter.3
  stable/11/contrib/libarchive/libarchive/archive_write_set_format_pax.c
  stable/11/contrib/libarchive/libarchive/test/test_archive_write_add_filter_by_name.c
  stable/11/contrib/libarchive/libarchive/test/test_fuzz.c
  stable/11/contrib/libarchive/tar/bsdtar.1
  stable/11/contrib/libarchive/tar/bsdtar.c
  stable/11/contrib/libarchive/tar/bsdtar.h
  stable/11/contrib/libarchive/tar/cmdline.c
  stable/11/contrib/libarchive/tar/creation_set.c
  stable/11/contrib/libarchive/tar/test/test_option_acls.c
  stable/11/contrib/libarchive/test_utils/test_common.h
  stable/11/contrib/libarchive/test_utils/test_main.c
  stable/11/lib/libarchive/Makefile
  stable/11/lib/libarchive/tests/Makefile
  stable/11/usr.bin/bsdcat/tests/Makefile
  stable/11/usr.bin/cpio/tests/Makefile
  stable/11/usr.bin/tar/tests/Makefile
Directory Properties:
  stable/11/   (props changed)

Copied: stable/11/contrib/libarchive/cat/test/test_empty.zst.uu (from r324148, head/contrib/libarchive/cat/test/test_empty.zst.uu)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/contrib/libarchive/cat/test/test_empty.zst.uu	Sun Oct  8 20:54:53 2017	(r324417, copy of r324148, head/contrib/libarchive/cat/test/test_empty.zst.uu)
@@ -0,0 +1,4 @@
+begin 644 test_empty.zst
+-*+4O_010`0``F>G840``
+`
+end

Copied: stable/11/contrib/libarchive/cat/test/test_empty_zstd.c (from r324148, head/contrib/libarchive/cat/test/test_empty_zstd.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/contrib/libarchive/cat/test/test_empty_zstd.c	Sun Oct  8 20:54:53 2017	(r324417, copy of r324148, head/contrib/libarchive/cat/test/test_empty_zstd.c)
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2017 Sean Purcell
+ * 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_empty_zstd)
+{
+	const char *reffile = "test_empty.zst";
+	int f;
+
+	extract_reference_file(reffile);
+	f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
+	if (f == 0 || canZstd()) {
+		assertEqualInt(0, f);
+		assertEmptyFile("test.out");
+		assertEmptyFile("test.err");
+	} else {
+		skipping("It seems zstd is not supported on this platform");
+	}
+}

Copied: stable/11/contrib/libarchive/cat/test/test_expand.zst.uu (from r324148, head/contrib/libarchive/cat/test/test_expand.zst.uu)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/contrib/libarchive/cat/test/test_expand.zst.uu	Sun Oct  8 20:54:53 2017	(r324417, copy of r324148, head/contrib/libarchive/cat/test/test_expand.zst.uu)
@@ -0,0 +1,4 @@
+begin 644 test_expand.zst
+J*+4O_010Z0``8V]N=&5N=',@;V8@=&5S=%]E>'!A;F0N>G-T+@J;23#F
+`
+end

Copied: stable/11/contrib/libarchive/cat/test/test_expand_zstd.c (from r324148, head/contrib/libarchive/cat/test/test_expand_zstd.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/contrib/libarchive/cat/test/test_expand_zstd.c	Sun Oct  8 20:54:53 2017	(r324417, copy of r324148, head/contrib/libarchive/cat/test/test_expand_zstd.c)
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2017 Sean Purcell
+ * 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_expand_zstd)
+{
+	const char *reffile = "test_expand.zst";
+	int f;
+
+	extract_reference_file(reffile);
+	f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
+	if (f == 0 || canZstd()) {
+		assertEqualInt(0, f);
+		assertTextFileContents("contents of test_expand.zst.\n", "test.out");
+		assertEmptyFile("test.err");
+	} else {
+		skipping("It seems zstd is not supported on this platform");
+	}
+}

Modified: stable/11/contrib/libarchive/cpio/bsdcpio.1
==============================================================================
--- stable/11/contrib/libarchive/cpio/bsdcpio.1	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/cpio/bsdcpio.1	Sun Oct  8 20:54:53 2017	(r324417)
@@ -187,6 +187,11 @@ In input mode, this option is ignored.
 Compress the archive with lz4-compatible compression before writing it.
 In input mode, this option is ignored; lz4 compression is recognized
 automatically on input.
+.It Fl Fl zstd
+(o mode only)
+Compress the archive with zstd-compatible compression before writing it.
+In input mode, this option is ignored; zstd compression is recognized
+automatically on input.
 .It Fl Fl lzma
 (o mode only)
 Compress the file with lzma-compatible compression before writing it.

Modified: stable/11/contrib/libarchive/cpio/cmdline.c
==============================================================================
--- stable/11/contrib/libarchive/cpio/cmdline.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/cpio/cmdline.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -92,6 +92,7 @@ static const struct option {
 	{ "verbose",			0, 'v' },
 	{ "version",			0, OPTION_VERSION },
 	{ "xz",				0, 'J' },
+	{ "zstd",			0, OPTION_ZSTD },
 	{ NULL, 0, 0 }
 };
 

Modified: stable/11/contrib/libarchive/cpio/cpio.c
==============================================================================
--- stable/11/contrib/libarchive/cpio/cpio.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/cpio/cpio.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -269,6 +269,7 @@ main(int argc, char *argv[])
 		case OPTION_LZ4:
 		case OPTION_LZMA: /* GNU tar, others */
 		case OPTION_LZOP: /* GNU tar, others */
+		case OPTION_ZSTD:
 			cpio->compress = opt;
 			break;
 		case 'm': /* POSIX 1997 */
@@ -545,6 +546,9 @@ mode_out(struct cpio *cpio)
 		break;
 	case OPTION_LZOP:
 		r = archive_write_add_filter_lzop(cpio->archive);
+		break;
+	case OPTION_ZSTD:
+		r = archive_write_add_filter_zstd(cpio->archive);
 		break;
 	case 'j': case 'y':
 		r = archive_write_add_filter_bzip2(cpio->archive);

Modified: stable/11/contrib/libarchive/cpio/cpio.h
==============================================================================
--- stable/11/contrib/libarchive/cpio/cpio.h	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/cpio/cpio.h	Sun Oct  8 20:54:53 2017	(r324417)
@@ -111,7 +111,8 @@ enum {
 	OPTION_PRESERVE_OWNER,
 	OPTION_QUIET,
 	OPTION_UUENCODE,
-	OPTION_VERSION
+	OPTION_VERSION,
+	OPTION_ZSTD,
 };
 
 int	cpio_getopt(struct cpio *cpio);

Copied: stable/11/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu (from r324148, head/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu	Sun Oct  8 20:54:53 2017	(r324417, copy of r324148, head/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu)
@@ -0,0 +1,6 @@
+begin 644 test_extract.cpio.zst
+M*+4O_01090,`,@41%X")&@#'G6T\K16_MR)#=DK)5:.1,2J0HY2"!(1!`!7R
+M$(UB`2"*D41;J2UF&)<0!Y7X'TU<%W.\W^R]GO-WW^OO^QX0`%P<]30-!#U`
+?!KD!`#XP,_`U4`HT3+RF:#!7Y\V@R)5"7P"^;WEUK@``
+`
+end

Copied: stable/11/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c (from r324148, head/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c	Sun Oct  8 20:54:53 2017	(r324417, copy of r324148, head/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c)
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2017 Sean Purcell
+ * 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_extract_cpio_zstd)
+{
+	const char *reffile = "test_extract.cpio.zst";
+	int f;
+
+	extract_reference_file(reffile);
+	f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
+	if (f == 0 || canZstd()) {
+		assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
+		    testprog, reffile));
+
+		assertFileExists("file1");
+		assertTextFileContents("contents of file1.\n", "file1");
+		assertFileExists("file2");
+		assertTextFileContents("contents of file2.\n", "file2");
+		assertEmptyFile("test.out");
+		assertTextFileContents("1 block\n", "test.err");
+	} else {
+		skipping("It seems zstd is not supported on this platform");
+	}
+}

Copied: stable/11/contrib/libarchive/cpio/test/test_option_zstd.c (from r324148, head/contrib/libarchive/cpio/test/test_option_zstd.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/contrib/libarchive/cpio/test/test_option_zstd.c	Sun Oct  8 20:54:53 2017	(r324417, copy of r324148, head/contrib/libarchive/cpio/test/test_option_zstd.c)
@@ -0,0 +1,85 @@
+/*-
+ * Copyright (c) 2017 Sean Purcell
+ * 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_option_zstd)
+{
+	char *p;
+	int r;
+	size_t s;
+
+	/* Create a file. */
+	assertMakeFile("f", 0644, "a");
+
+	/* Archive it with zstd compression. */
+	r = systemf("echo f | %s -o --zstd >archive.out 2>archive.err",
+	    testprog);
+	p = slurpfile(&s, "archive.err");
+	p[s] = '\0';
+	if (r != 0) {
+		if (strstr(p, "Unsupported compression") != NULL) {
+			skipping("This version of bsdcpio was compiled "
+			    "without zstd support");
+			goto done;
+		}
+		/* POSIX permits different handling of the spawnp
+		 * system call used to launch the subsidiary
+		 * program: */
+		/* Some systems fail immediately to spawn the new process. */
+		if (strstr(p, "Can't launch") != NULL && !canZstd()) {
+			skipping("This version of bsdcpio uses an external zstd program "
+			    "but no such program is available on this system.");
+			goto done;
+		}
+		/* Some systems successfully spawn the new process,
+		 * but fail to exec a program within that process.
+		 * This results in failure at the first attempt to
+		 * write. */
+		if (strstr(p, "Can't write") != NULL && !canZstd()) {
+			skipping("This version of bsdcpio uses an external zstd program "
+			    "but no such program is available on this system.");
+			goto done;
+		}
+		/* On some systems the error won't be detected until closing
+		   time, by a 127 exit error returned by waitpid. */
+		if (strstr(p, "Error closing") != NULL && !canZstd()) {
+			skipping("This version of bsdcpio uses an external zstd program "
+			    "but no such program is available on this system.");
+			return;
+		}
+		failure("--zstd option is broken: %s", p);
+		assertEqualInt(r, 0);
+		goto done;
+	}
+	free(p);
+	/* Check that the archive file has an zstd signature. */
+	p = slurpfile(&s, "archive.out");
+	assert(s > 2);
+	assertEqualMem(p, "\x28\xb5\x2f\xfd", 4);
+
+done:
+	free(p);
+}

Modified: stable/11/contrib/libarchive/libarchive/archive.h
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive.h	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive.h	Sun Oct  8 20:54:53 2017	(r324417)
@@ -177,6 +177,7 @@ __LA_DECL const char *  archive_zlib_version(void);
 __LA_DECL const char *  archive_liblzma_version(void);
 __LA_DECL const char *  archive_bzlib_version(void);
 __LA_DECL const char *  archive_liblz4_version(void);
+__LA_DECL const char *  archive_libzstd_version(void);
 
 /* Declare our basic types. */
 struct archive;
@@ -276,6 +277,7 @@ typedef const char *archive_passphrase_callback(struct
 #define	ARCHIVE_FILTER_LZOP	11
 #define	ARCHIVE_FILTER_GRZIP	12
 #define	ARCHIVE_FILTER_LZ4	13
+#define	ARCHIVE_FILTER_ZSTD	14
 
 #if ARCHIVE_VERSION_NUMBER < 4000000
 #define	ARCHIVE_COMPRESSION_NONE	ARCHIVE_FILTER_NONE
@@ -433,6 +435,7 @@ __LA_DECL int archive_read_support_filter_program_sign
 __LA_DECL int archive_read_support_filter_rpm(struct archive *);
 __LA_DECL int archive_read_support_filter_uu(struct archive *);
 __LA_DECL int archive_read_support_filter_xz(struct archive *);
+__LA_DECL int archive_read_support_filter_zstd(struct archive *);
 
 __LA_DECL int archive_read_support_format_7zip(struct archive *);
 __LA_DECL int archive_read_support_format_all(struct archive *);
@@ -778,6 +781,7 @@ __LA_DECL int archive_write_add_filter_program(struct 
 		     const char *cmd);
 __LA_DECL int archive_write_add_filter_uuencode(struct archive *);
 __LA_DECL int archive_write_add_filter_xz(struct archive *);
+__LA_DECL int archive_write_add_filter_zstd(struct archive *);
 
 
 /* A convenience function to set the format based on the code or name. */

Modified: stable/11/contrib/libarchive/libarchive/archive_cmdline.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_cmdline.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_cmdline.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -100,10 +100,10 @@ get_argument(struct archive_string *as, const char *p)
 
 /*
  * Set up command line arguments.
- * Returns ARChIVE_OK if everything okey.
- * Returns ARChIVE_FAILED if there is a lack of the `"' terminator or an
+ * Returns ARCHIVE_OK if everything okey.
+ * Returns ARCHIVE_FAILED if there is a lack of the `"' terminator or an
  * empty command line.
- * Returns ARChIVE_FATAL if no memory.
+ * Returns ARCHIVE_FATAL if no memory.
  */
 int
 __archive_cmdline_parse(struct archive_cmdline *data, const char *cmd)

Modified: stable/11/contrib/libarchive/libarchive/archive_platform.h
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_platform.h	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_platform.h	Sun Oct  8 20:54:53 2017	(r324417)
@@ -52,6 +52,17 @@
 #error Oops: No config.h and no pre-built configuration in archive_platform.h.
 #endif
 
+/* On macOS check for some symbols based on the deployment target version.  */
+#if defined(__APPLE__)
+# undef HAVE_FUTIMENS
+# undef HAVE_UTIMENSAT
+# include <AvailabilityMacros.h>
+# if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
+#  define HAVE_FUTIMENS 1
+#  define HAVE_UTIMENSAT 1
+# endif
+#endif
+
 /* It should be possible to get rid of this by extending the feature-test
  * macros to cover Windows API functions, probably along with non-trivial
  * refactoring of code to find structures that sit more cleanly on top of

Modified: stable/11/contrib/libarchive/libarchive/archive_read_append_filter.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_append_filter.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_read_append_filter.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -89,6 +89,10 @@ archive_read_append_filter(struct archive *_a, int cod
       strcpy(str, "lz4");
       r1 = archive_read_support_filter_lz4(_a);
       break;
+    case ARCHIVE_FILTER_ZSTD:
+      strcpy(str, "zstd");
+      r1 = archive_read_support_filter_zstd(_a);
+      break;
     case ARCHIVE_FILTER_LZIP:
       strcpy(str, "lzip");
       r1 = archive_read_support_filter_lzip(_a);

Modified: stable/11/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -127,7 +127,7 @@ archive_read_disk_entry_setup_acls(struct archive_read
 /*
  * Enter working directory and return working pathname of archive_entry.
  * If a pointer to an integer is provided and its value is below zero
- * open a file descriptor on this pahtname.
+ * open a file descriptor on this pathname.
  */
 const char *
 archive_read_disk_entry_setup_path(struct archive_read_disk *a,

Modified: stable/11/contrib/libarchive/libarchive/archive_read_filter.3
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_filter.3	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_read_filter.3	Sun Oct  8 20:54:53 2017	(r324417)
@@ -38,6 +38,7 @@
 .Nm archive_read_support_filter_rpm ,
 .Nm archive_read_support_filter_uu ,
 .Nm archive_read_support_filter_xz ,
+.Nm archive_read_support_filter_zstd ,
 .Nm archive_read_support_filter_program ,
 .Nm archive_read_support_filter_program_signature
 .Nd functions for reading streaming archives
@@ -73,6 +74,8 @@ Streaming Archive Library (libarchive, -larchive)
 .Ft int
 .Fn archive_read_support_filter_xz "struct archive *"
 .Ft int
+.Fn archive_read_support_filter_zstd "struct archive *"
+.Ft int
 .Fo archive_read_support_filter_program
 .Fa "struct archive *"
 .Fa "const char *cmd"
@@ -99,7 +102,8 @@ Streaming Archive Library (libarchive, -larchive)
 .Fn archive_read_support_filter_none ,
 .Fn archive_read_support_filter_rpm ,
 .Fn archive_read_support_filter_uu ,
-.Fn archive_read_support_filter_xz
+.Fn archive_read_support_filter_xz ,
+.Fn archive_read_support_filter_zstd ,
 .Xc
 Enables auto-detection code and decompression support for the
 specified compression.

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_filter_all.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_filter_all.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_filter_all.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -71,6 +71,8 @@ archive_read_support_filter_all(struct archive *a)
 	archive_read_support_filter_grzip(a);
 	/* Lz4 falls back to "lz4 -d" command-line program. */
 	archive_read_support_filter_lz4(a);
+	/* Zstd falls back to "zstd -d" command-line program. */
+	archive_read_support_filter_zstd(a);
 
 	/* Note: We always return ARCHIVE_OK here, even if some of the
 	 * above return ARCHIVE_WARN.  The intent here is to enable

Copied: stable/11/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c (from r324148, head/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c	Sun Oct  8 20:54:53 2017	(r324417, copy of r324148, head/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c)
@@ -0,0 +1,292 @@
+/*-
+ * Copyright (c) 2009-2011 Sean Purcell
+ * 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 "archive_platform.h"
+
+__FBSDID("$FreeBSD$");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_ZSTD_H
+#include <zstd.h>
+#endif
+
+#include "archive.h"
+#include "archive_endian.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+
+struct private_data {
+	ZSTD_DStream	*dstream;
+	unsigned char	*out_block;
+	size_t		 out_block_size;
+	int64_t		 total_out;
+	char		 in_frame; /* True = in the middle of a zstd frame. */
+	char		 eof; /* True = found end of compressed data. */
+};
+
+/* Zstd Filter. */
+static ssize_t	zstd_filter_read(struct archive_read_filter *, const void**);
+static int	zstd_filter_close(struct archive_read_filter *);
+#endif
+
+/*
+ * Note that we can detect zstd compressed files even if we can't decompress
+ * them.  (In fact, we like detecting them because we can give better error
+ * messages.)  So the bid framework here gets compiled even if no zstd library
+ * is available.
+ */
+static int	zstd_bidder_bid(struct archive_read_filter_bidder *,
+		    struct archive_read_filter *);
+static int	zstd_bidder_init(struct archive_read_filter *);
+
+int
+archive_read_support_filter_zstd(struct archive *_a)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	struct archive_read_filter_bidder *bidder;
+
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_filter_zstd");
+
+	if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
+		return (ARCHIVE_FATAL);
+
+	bidder->data = NULL;
+	bidder->name = "zstd";
+	bidder->bid = zstd_bidder_bid;
+	bidder->init = zstd_bidder_init;
+	bidder->options = NULL;
+	bidder->free = NULL;
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+	return (ARCHIVE_OK);
+#else
+	archive_set_error(_a, ARCHIVE_ERRNO_MISC,
+	    "Using external zstd program for zstd decompression");
+	return (ARCHIVE_WARN);
+#endif
+}
+
+/*
+ * Test whether we can handle this data.
+ */
+static int
+zstd_bidder_bid(struct archive_read_filter_bidder *self,
+    struct archive_read_filter *filter)
+{
+	const unsigned char *buffer;
+	ssize_t avail;
+	unsigned prefix;
+
+	/* Zstd frame magic values */
+	const unsigned zstd_magic = 0xFD2FB528U;
+
+	(void) self; /* UNUSED */
+
+	buffer = __archive_read_filter_ahead(filter, 4, &avail);
+	if (buffer == NULL)
+		return (0);
+
+	prefix = archive_le32dec(buffer);
+	if (prefix == zstd_magic)
+		return (32);
+
+	return (0);
+}
+
+#if !(HAVE_ZSTD_H && HAVE_LIBZSTD)
+
+/*
+ * If we don't have the library on this system, we can't do the
+ * decompression directly.  We can, however, try to run "zstd -d"
+ * in case that's available.
+ */
+static int
+zstd_bidder_init(struct archive_read_filter *self)
+{
+	int r;
+
+	r = __archive_read_program(self, "zstd -d -qq");
+	/* Note: We set the format here even if __archive_read_program()
+	 * above fails.  We do, after all, know what the format is
+	 * even if we weren't able to read it. */
+	self->code = ARCHIVE_FILTER_ZSTD;
+	self->name = "zstd";
+	return (r);
+}
+
+#else
+
+/*
+ * Initialize the filter object
+ */
+static int
+zstd_bidder_init(struct archive_read_filter *self)
+{
+	struct private_data *state;
+	const size_t out_block_size = ZSTD_DStreamOutSize();
+	void *out_block;
+	ZSTD_DStream *dstream;
+
+	self->code = ARCHIVE_FILTER_ZSTD;
+	self->name = "zstd";
+
+	state = (struct private_data *)calloc(sizeof(*state), 1);
+	out_block = (unsigned char *)malloc(out_block_size);
+	dstream = ZSTD_createDStream();
+
+	if (state == NULL || out_block == NULL || dstream == NULL) {
+		free(out_block);
+		free(state);
+		ZSTD_freeDStream(dstream); /* supports free on NULL */
+		archive_set_error(&self->archive->archive, ENOMEM,
+		    "Can't allocate data for zstd decompression");
+		return (ARCHIVE_FATAL);
+	}
+
+	self->data = state;
+
+	state->out_block_size = out_block_size;
+	state->out_block = out_block;
+	state->dstream = dstream;
+	self->read = zstd_filter_read;
+	self->skip = NULL; /* not supported */
+	self->close = zstd_filter_close;
+
+	state->eof = 0;
+	state->in_frame = 0;
+
+	return (ARCHIVE_OK);
+}
+
+static ssize_t
+zstd_filter_read(struct archive_read_filter *self, const void **p)
+{
+	struct private_data *state;
+	size_t decompressed;
+	ssize_t avail_in;
+	ZSTD_outBuffer out;
+	ZSTD_inBuffer in;
+
+	state = (struct private_data *)self->data;
+
+	out = (ZSTD_outBuffer) { state->out_block, state->out_block_size, 0 };
+
+	/* Try to fill the output buffer. */
+	while (out.pos < out.size && !state->eof) {
+		if (!state->in_frame) {
+			const size_t ret = ZSTD_initDStream(state->dstream);
+			if (ZSTD_isError(ret)) {
+				archive_set_error(&self->archive->archive,
+				    ARCHIVE_ERRNO_MISC,
+				    "Error initializing zstd decompressor: %s",
+				    ZSTD_getErrorName(ret));
+				return (ARCHIVE_FATAL);
+			}
+		}
+		in.src = __archive_read_filter_ahead(self->upstream, 1,
+		    &avail_in);
+		if (avail_in < 0) {
+			return avail_in;
+		}
+		if (in.src == NULL && avail_in == 0) {
+			if (!state->in_frame) {
+				/* end of stream */
+				state->eof = 1;
+				break;
+			} else {
+				archive_set_error(&self->archive->archive,
+				    ARCHIVE_ERRNO_MISC,
+				    "Truncated zstd input");
+				return (ARCHIVE_FATAL);
+			}
+		}
+		in.size = avail_in;
+		in.pos = 0;
+
+		{
+			const size_t ret =
+			    ZSTD_decompressStream(state->dstream, &out, &in);
+
+			if (ZSTD_isError(ret)) {
+				archive_set_error(&self->archive->archive,
+				    ARCHIVE_ERRNO_MISC,
+				    "Zstd decompression failed: %s",
+				    ZSTD_getErrorName(ret));
+				return (ARCHIVE_FATAL);
+			}
+
+			/* Decompressor made some progress */
+			__archive_read_filter_consume(self->upstream, in.pos);
+
+			/* ret guaranteed to be > 0 if frame isn't done yet */
+			state->in_frame = (ret != 0);
+		}
+	}
+
+	decompressed = out.pos;
+	state->total_out += decompressed;
+	if (decompressed == 0)
+		*p = NULL;
+	else
+		*p = state->out_block;
+	return (decompressed);
+}
+
+/*
+ * Clean up the decompressor.
+ */
+static int
+zstd_filter_close(struct archive_read_filter *self)
+{
+	struct private_data *state;
+
+	state = (struct private_data *)self->data;
+
+	ZSTD_freeDStream(state->dstream);
+	free(state->out_block);
+	free(state);
+
+	return (ARCHIVE_OK);
+}
+
+#endif /* HAVE_ZLIB_H && HAVE_LIBZSTD */

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_cpio.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_format_cpio.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_cpio.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -633,6 +633,13 @@ header_newc(struct archive_read *a, struct cpio *cpio,
 	/* Pad name to 2 more than a multiple of 4. */
 	*name_pad = (2 - *namelength) & 3;
 
+	/* Make sure that the padded name length fits into size_t. */
+	if (*name_pad > SIZE_MAX - *namelength) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "cpio archive has invalid namelength");
+		return (ARCHIVE_FATAL);
+	}
+
 	/*
 	 * Note: entry_bytes_remaining is at least 64 bits and
 	 * therefore guaranteed to be big enough for a 33-bit file

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -77,6 +77,8 @@ __FBSDID("$FreeBSD$");
 
 #define	MTREE_HASHTABLE_SIZE 1024
 
+#define	MAX_LINE_LEN		(1024 * 1024)
+
 struct mtree_option {
 	struct mtree_option *next;
 	char *value;
@@ -333,6 +335,14 @@ next_line(struct archive_read *a,
 		ssize_t diff = *ravail - *avail;
 		size_t nbytes_req = (*ravail+1023) & ~1023U;
 		ssize_t tested;
+
+		/*
+		 * Place an arbitrary limit on the line length.
+		 * mtree is almost free-form input and without line length limits,
+		 * it can consume a lot of memory.
+		 */
+		if (len >= MAX_LINE_LEN)
+			return (-1);
 
 		/* Increase reading bytes if it is not enough to at least
 		 * new two lines. */

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_rar.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_format_rar.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_rar.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -1496,7 +1496,11 @@ read_header(struct archive_read *a, struct archive_ent
         return (ARCHIVE_FATAL);
       }
       filename[filename_size++] = '\0';
-      filename[filename_size++] = '\0';
+      /*
+       * Do not increment filename_size here as the computations below
+       * add the space for the terminating NUL explicitly.
+       */
+      filename[filename_size] = '\0';
 
       /* Decoded unicode form is UTF-16BE, so we have to update a string
        * conversion object for it. */

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_tar.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_format_tar.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_tar.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -2243,7 +2243,7 @@ gnu_add_sparse_entry(struct archive_read *a, struct ta
 	else
 		tar->sparse_list = p;
 	tar->sparse_last = p;
-	if (remaining < 0 || offset < 0) {
+	if (remaining < 0 || offset < 0 || offset > INT64_MAX - remaining) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Malformed sparse map data");
 		return (ARCHIVE_FATAL);
 	}

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_xar.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_format_xar.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_xar.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -1040,6 +1040,9 @@ atol10(const char *p, size_t char_cnt)
 	uint64_t l;
 	int digit;
 
+	if (char_cnt == 0)
+		return (0);
+
 	l = 0;
 	digit = *p - '0';
 	while (digit >= 0 && digit < 10  && char_cnt-- > 0) {
@@ -1054,7 +1057,10 @@ atol8(const char *p, size_t char_cnt)
 {
 	int64_t l;
 	int digit;
-        
+
+	if (char_cnt == 0)
+		return (0);
+
 	l = 0;
 	while (char_cnt-- > 0) {
 		if (*p >= '0' && *p <= '7')
@@ -2623,6 +2629,14 @@ strappend_base64(struct xar *xar,
 		archive_strncat(as, (const char *)buff, len);
 }
 
+static int
+is_string(const char *known, const char *data, size_t len)
+{
+	if (strlen(known) != len)
+		return -1;
+	return memcmp(data, known, len);
+}
+
 static void
 xml_data(void *userData, const char *s, int len)
 {
@@ -2674,26 +2688,26 @@ xml_data(void *userData, const char *s, int len)
 		archive_strncpy(&(xar->file->symlink), s, len);
 		break;
 	case FILE_TYPE:
-		if (strncmp("file", s, len) == 0 ||
-		    strncmp("hardlink", s, len) == 0)
+		if (is_string("file", s, len) == 0 ||
+		    is_string("hardlink", s, len) == 0)
 			xar->file->mode =
 			    (xar->file->mode & ~AE_IFMT) | AE_IFREG;
-		if (strncmp("directory", s, len) == 0)
+		if (is_string("directory", s, len) == 0)
 			xar->file->mode =
 			    (xar->file->mode & ~AE_IFMT) | AE_IFDIR;
-		if (strncmp("symlink", s, len) == 0)
+		if (is_string("symlink", s, len) == 0)
 			xar->file->mode =
 			    (xar->file->mode & ~AE_IFMT) | AE_IFLNK;
-		if (strncmp("character special", s, len) == 0)
+		if (is_string("character special", s, len) == 0)
 			xar->file->mode =
 			    (xar->file->mode & ~AE_IFMT) | AE_IFCHR;
-		if (strncmp("block special", s, len) == 0)
+		if (is_string("block special", s, len) == 0)
 			xar->file->mode =
 			    (xar->file->mode & ~AE_IFMT) | AE_IFBLK;
-		if (strncmp("socket", s, len) == 0)
+		if (is_string("socket", s, len) == 0)
 			xar->file->mode =
 			    (xar->file->mode & ~AE_IFMT) | AE_IFSOCK;
-		if (strncmp("fifo", s, len) == 0)
+		if (is_string("fifo", s, len) == 0)
 			xar->file->mode =
 			    (xar->file->mode & ~AE_IFMT) | AE_IFIFO;
 		xar->file->has |= HAS_TYPE;

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_zip.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_format_zip.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_zip.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -723,6 +723,11 @@ process_extra(struct archive_read *a, const char *p, s
 		}
 		case 0x9901:
 			/* WinZip AES extra data field. */
+			if (datasize < 6) {
+				archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+				    "Incomplete AES field");
+				return ARCHIVE_FAILED;
+			}
 			if (p[offset + 2] == 'A' && p[offset + 3] == 'E') {
 				/* Vendor version. */
 				zip_entry->aes_extra.vendor =

Modified: stable/11/contrib/libarchive/libarchive/archive_string.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_string.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_string.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -214,7 +214,8 @@ archive_wstring_append(struct archive_wstring *as, con
 {
 	if (archive_wstring_ensure(as, as->length + s + 1) == NULL)
 		return (NULL);
-	wmemmove(as->s + as->length, p, s);
+	if (s)
+		wmemmove(as->s + as->length, p, s);
 	as->length += s;
 	as->s[as->length] = 0;
 	return (as);

Modified: stable/11/contrib/libarchive/libarchive/archive_version_details.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_version_details.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_version_details.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -45,6 +45,9 @@ __FBSDID("$FreeBSD$");
 #ifdef HAVE_LZ4_H
 #include <lz4.h>
 #endif
+#ifdef HAVE_ZSTD_H
+#include <zstd.h>
+#endif
 
 #include "archive.h"
 #include "archive_private.h"
@@ -59,6 +62,7 @@ archive_version_details(void)
 	const char *liblzma = archive_liblzma_version();
 	const char *bzlib = archive_bzlib_version();
 	const char *liblz4 = archive_liblz4_version();
+	const char *libzstd = archive_libzstd_version();
 
 	if (!init) {
 		archive_string_init(&str);
@@ -84,6 +88,10 @@ archive_version_details(void)
 			archive_strcat(&str, " liblz4/");
 			archive_strcat(&str, liblz4);
 		}
+		if (libzstd) {
+			archive_strcat(&str, " libzstd/");
+			archive_strcat(&str, libzstd);
+		}
 	}
 	return str.s;
 }
@@ -127,6 +135,16 @@ archive_liblz4_version(void)
 	return NUMBER(LZ4_VERSION_MAJOR) "." NUMBER(LZ4_VERSION_MINOR) "." NUMBER(LZ4_VERSION_RELEASE);
 #undef NUMBER
 #undef str
+#else
+	return NULL;
+#endif
+}
+
+const char *
+archive_libzstd_version(void)
+{
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+	return ZSTD_VERSION_STRING;
 #else
 	return NULL;
 #endif

Modified: stable/11/contrib/libarchive/libarchive/archive_write.3
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_write.3	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_write.3	Sun Oct  8 20:54:53 2017	(r324417)
@@ -71,7 +71,7 @@ support.
 .\"
 .Ss Set options
 See
-.Xr archive_read_set_options 3 .
+.Xr archive_write_set_options 3 .
 .\"
 .Ss Open archive
 See

Modified: stable/11/contrib/libarchive/libarchive/archive_write_add_filter.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_write_add_filter.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_write_add_filter.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -53,6 +53,7 @@ struct { int code; int (*setter)(struct archive *); } 
 	{ ARCHIVE_FILTER_LZOP,		archive_write_add_filter_lzip },
 	{ ARCHIVE_FILTER_UU,		archive_write_add_filter_uuencode },
 	{ ARCHIVE_FILTER_XZ,		archive_write_add_filter_xz },
+	{ ARCHIVE_FILTER_ZSTD,		archive_write_add_filter_zstd },
 	{ -1,			NULL }
 };
 

Modified: stable/11/contrib/libarchive/libarchive/archive_write_add_filter_by_name.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_write_add_filter_by_name.c	Sun Oct  8 18:38:22 2017	(r324416)
+++ stable/11/contrib/libarchive/libarchive/archive_write_add_filter_by_name.c	Sun Oct  8 20:54:53 2017	(r324417)
@@ -57,6 +57,7 @@ struct { const char *name; int (*setter)(struct archiv
 	{ "lzop",		archive_write_add_filter_lzop },
 	{ "uuencode",		archive_write_add_filter_uuencode },
 	{ "xz",			archive_write_add_filter_xz },
+	{ "zstd",		archive_write_add_filter_zstd },
 	{ NULL,			NULL }
 };
 

Copied: stable/11/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c (from r324148, head/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c	Sun Oct  8 20:54:53 2017	(r324417, copy of r324148, head/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c)
@@ -0,0 +1,335 @@
+/*-
+ * Copyright (c) 2017 Sean Purcell
+ * 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

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710082054.v98Ksr4N079065>