Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Jun 2019 10:35:55 +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: r348607 - in stable/11: contrib/libarchive contrib/libarchive/cpio/test contrib/libarchive/libarchive contrib/libarchive/libarchive/test contrib/libarchive/tar contrib/libarchive/tar/te...
Message-ID:  <201906041035.x54AZte3080625@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mm
Date: Tue Jun  4 10:35:54 2019
New Revision: 348607
URL: https://svnweb.freebsd.org/changeset/base/348607

Log:
  MFC r347990:
  Sync libarchive with vendor.
  
  Relevant vendor changes:
    Issue #795: XAR - do not try to add xattrs without an allocated name
    PR #812: non-recursive option for extract and list
    PR #958: support reading metadata from compressed files
    PR #999: add --exclude-vcs option to bsdtar
    Issue #1062: treat empty archives with a GNU volume header as valid
    PR #1074: Handle ZIP files with trailing 0s in the extra fields
              (Android APK archives)
    PR #1109: Ignore padding in Zip extra field data (Android APK archives)
    PR #1167: fix problems related to unreadable directories
    Issue #1168: fix handling of strtol() and strtoul()
    PR #1172: RAR5 - fix invalid window buffer read in E8E9 filter
    PR #1174: ZIP reader - fix of MSZIP signature parsing
    PR #1175: gzip filter - fix reading files larger than 4GB from memory
    PR #1177: gzip filter - fix memory leak with repeated header reads
    PR #1180: ZIP reader - add support for Info-ZIP Unicode Path Extra Field
    PR #1181: RAR5 - fix merge_block() recursion
              (OSS-Fuzz 12999, 13029, 13144, 13478, 13490)
    PR #1183: fix memory leak when decompressing ZIP files with LZMA
    PR #1184: fix RAR5 OSS-Fuzz issues 12466, 14490, 14491, 12817
      OSS-Fuzz 12466: RAR5 - fix buffer overflow when parsing huffman tables
      OSS-Fuzz 14490, 14491: RAR5 - fix bad shift-left operations
      OSS-Fuzz 12817: RAR5 - handle a case with truncated huffman tables
    PR #1186: RAR5 - fix invalid type used for dictionary size mask
              (OSS-Fuzz 14537)
    PR #1187: RAR5 - fix integer overflow (OSS-Fuzz 14555)
    PR #1190: RAR5 - RAR5 don't try to unpack entries marked as directories
              (OSS-Fuzz 14574)
    PR #1196: RAR5 - fix a potential SIGSEGV on 32-bit builds
    OSS-Fuzz 2582: RAR - fix use after free if there is an invalid entry
    OSS-Fuzz 14331: RAR5 - fix maximum owner name length
    OSS-Fuzz 13965: RAR5 - use unsigned int for volume number + range check
  
    Additional RAR5 reader changes:
      - support symlinks, hardlinks, file owner, file group, versioned files
      - change ARCHIVE_FORMAT_RAR_V5 to 0x100000
      - set correct mode for readonly directories
      - support readonly, hidden and system Windows file attributes
  
  MFC r347999:
  Install missing data file for
  lib.libarchive.functional_test.test_read_format_zip_utf8_paths
  
  Approved by:	re (gjb blanket)

Added:
  stable/11/contrib/libarchive/libarchive/archive_entry_misc.3
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/archive_entry_misc.3
  stable/11/contrib/libarchive/libarchive/test/test_read_format_mtree_noprint.mtree.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_mtree_noprint.mtree.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_distance_overflow.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_distance_overflow.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_extra_field_version.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_extra_field_version.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_fileattr.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_fileattr.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_hardlink.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_hardlink.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_invalid_dict_reference.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_invalid_dict_reference.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_leftshift1.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_leftshift1.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_leftshift2.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_leftshift2.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_nonempty_dir_stream.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_nonempty_dir_stream.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_owner.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_owner.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_readtables_overflow.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_readtables_overflow.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_symlink.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_symlink.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_truncated_huff.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_truncated_huff.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar_ppmd_use_after_free.rar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar_ppmd_use_after_free.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_raw.data.gz.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_raw.data.gz.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_tar_empty_with_gnulabel.c
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_with_gnulabel.c
  stable/11/contrib/libarchive/libarchive/test/test_read_format_tar_empty_with_gnulabel.tar.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_with_gnulabel.tar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_zip_7075_utf8_paths.c
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_zip_7075_utf8_paths.c
  stable/11/contrib/libarchive/libarchive/test/test_read_format_zip_7075_utf8_paths.zip.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_zip_7075_utf8_paths.zip.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_zip_extra_padding.c
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_zip_extra_padding.c
  stable/11/contrib/libarchive/libarchive/test/test_read_format_zip_extra_padding.zip.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_zip_extra_padding.zip.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_zip_lzma_alone_leak.zipx.uu
     - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_zip_lzma_alone_leak.zipx.uu
  stable/11/contrib/libarchive/tar/test/test_option_exclude_vcs.c
     - copied unchanged from r347990, head/contrib/libarchive/tar/test/test_option_exclude_vcs.c
Modified:
  stable/11/contrib/libarchive/NEWS
  stable/11/contrib/libarchive/cpio/test/test_basic.c
  stable/11/contrib/libarchive/cpio/test/test_format_newc.c
  stable/11/contrib/libarchive/cpio/test/test_gcpio_compat.c
  stable/11/contrib/libarchive/cpio/test/test_option_L_upper.c
  stable/11/contrib/libarchive/cpio/test/test_option_a.c
  stable/11/contrib/libarchive/cpio/test/test_option_c.c
  stable/11/contrib/libarchive/libarchive/archive.h
  stable/11/contrib/libarchive/libarchive/archive_entry.c
  stable/11/contrib/libarchive/libarchive/archive_entry.h
  stable/11/contrib/libarchive/libarchive/archive_entry_private.h
  stable/11/contrib/libarchive/libarchive/archive_hmac.c
  stable/11/contrib/libarchive/libarchive/archive_match.c
  stable/11/contrib/libarchive/libarchive/archive_platform.h
  stable/11/contrib/libarchive/libarchive/archive_read.c
  stable/11/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
  stable/11/contrib/libarchive/libarchive/archive_read_disk_posix.c
  stable/11/contrib/libarchive/libarchive/archive_read_private.h
  stable/11/contrib/libarchive/libarchive/archive_read_set_format.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_filter_gzip.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_format_cab.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_rar5.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_format_raw.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_format_tar.c
  stable/11/contrib/libarchive/libarchive/archive_read_support_format_warc.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_util.c
  stable/11/contrib/libarchive/libarchive/archive_write_add_filter_xz.c
  stable/11/contrib/libarchive/libarchive/archive_write_disk_posix.c
  stable/11/contrib/libarchive/libarchive/archive_write_set_format_pax.c
  stable/11/contrib/libarchive/libarchive/archive_write_set_format_xar.c
  stable/11/contrib/libarchive/libarchive/test/test_entry.c
  stable/11/contrib/libarchive/libarchive/test/test_fuzz.c
  stable/11/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c
  stable/11/contrib/libarchive/libarchive/test/test_read_extract.c
  stable/11/contrib/libarchive/libarchive/test/test_read_format_mtree.c
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar.c
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5.c
  stable/11/contrib/libarchive/libarchive/test/test_read_format_rar5_win32.rar.uu
  stable/11/contrib/libarchive/libarchive/test/test_read_format_raw.c
  stable/11/contrib/libarchive/libarchive/test/test_read_format_zip.c
  stable/11/contrib/libarchive/libarchive/test/test_sparse_basic.c
  stable/11/contrib/libarchive/libarchive/test/test_write_disk_symlink.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/test/test_basic.c
  stable/11/contrib/libarchive/tar/test/test_copy.c
  stable/11/contrib/libarchive/tar/test/test_option_C_mtree.c
  stable/11/contrib/libarchive/tar/test/test_option_H_upper.c
  stable/11/contrib/libarchive/tar/test/test_option_L_upper.c
  stable/11/contrib/libarchive/tar/test/test_option_U_upper.c
  stable/11/contrib/libarchive/tar/test/test_option_n.c
  stable/11/contrib/libarchive/tar/test/test_option_s.c
  stable/11/contrib/libarchive/tar/test/test_strip_components.c
  stable/11/contrib/libarchive/tar/test/test_symlink_dir.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/tar/tests/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/libarchive/NEWS
==============================================================================
--- stable/11/contrib/libarchive/NEWS	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/NEWS	Tue Jun  4 10:35:54 2019	(r348607)
@@ -1,3 +1,13 @@
+Apr 16, 2019: Support for non-recursive list and extract
+
+Apr 14, 2019: New tar option: --exclude-vcs
+
+Mar 27, 2019: Support for file and directory symlinks on Windows
+
+Mar 12, 2019: Important fixes for storing file attributes and flags
+
+Jan 20, 2019: Support for xz, lzma, ppmd8 and bzip2 compression in zip archives
+
 Oct 06, 2018: RAR 5.0 reader
 
 Sep 03, 2018: libarchive 3.3.3 released

Modified: stable/11/contrib/libarchive/cpio/test/test_basic.c
==============================================================================
--- stable/11/contrib/libarchive/cpio/test/test_basic.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/cpio/test/test_basic.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -46,7 +46,7 @@ verify_files(const char *msg)
 
 	/* Symlink */
 	if (canSymlink())
-		assertIsSymlink("symlink", "file");
+		assertIsSymlink("symlink", "file", 0);
 
 	/* Another file with 1 link and different permissions. */
 	failure(msg);
@@ -173,7 +173,7 @@ DEFINE_TEST(test_basic)
 
 	/* Symlink to above file. */
 	if (canSymlink()) {
-		assertMakeSymlink("symlink", "file");
+		assertMakeSymlink("symlink", "file", 0);
 		fprintf(filelist, "symlink\n");
 		if (is_LargeInode("symlink")) {
 			strncat(result,

Modified: stable/11/contrib/libarchive/cpio/test/test_format_newc.c
==============================================================================
--- stable/11/contrib/libarchive/cpio/test/test_format_newc.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/cpio/test/test_format_newc.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -114,7 +114,7 @@ DEFINE_TEST(test_format_newc)
 
 	/* "symlink" */
 	if (canSymlink()) {
-		assertMakeSymlink("symlink", "file1");
+		assertMakeSymlink("symlink", "file1", 0);
 		fprintf(list, "symlink\n");
 	}
 
@@ -233,7 +233,12 @@ DEFINE_TEST(test_format_newc)
 		assert(is_hex(e, 110));
 		assertEqualMem(e + 0, "070701", 6); /* Magic */
 		assert(is_hex(e + 6, 8)); /* ino */
+#if defined(_WIN32) && !defined(CYGWIN)
+		/* Mode: Group members bits and others bits do not work. */
+		assertEqualInt(0xa180, from_hex(e + 14, 8) & 0xffc0);
+#else
 		assertEqualInt(0xa1ff, from_hex(e + 14, 8)); /* Mode */
+#endif
 		assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
 		assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
 		assertEqualMem(e + 38, "00000001", 8); /* nlink */

Modified: stable/11/contrib/libarchive/cpio/test/test_gcpio_compat.c
==============================================================================
--- stable/11/contrib/libarchive/cpio/test/test_gcpio_compat.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/cpio/test/test_gcpio_compat.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -71,7 +71,7 @@ unpack_test(const char *from, const char *options, con
 
 	/* Symlink */
 	if (canSymlink())
-		assertIsSymlink("symlink", "file");
+		assertIsSymlink("symlink", "file", 0);
 
 	/* dir */
 	assertIsDir("dir", 0775);

Modified: stable/11/contrib/libarchive/cpio/test/test_option_L_upper.c
==============================================================================
--- stable/11/contrib/libarchive/cpio/test/test_option_L_upper.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/cpio/test/test_option_L_upper.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -30,8 +30,10 @@ __FBSDID("$FreeBSD$");
  * tests won't run on Windows. */
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #define CAT "type"
+#define SEP "\\"
 #else
 #define CAT "cat"
+#define SEP "/"
 #endif
 
 DEFINE_TEST(test_option_L_upper)
@@ -51,7 +53,7 @@ DEFINE_TEST(test_option_L_upper)
 	fprintf(filelist, "file\n");
 
 	/* Symlink to above file. */
-	assertMakeSymlink("symlink", "file");
+	assertMakeSymlink("symlink", "file", 0);
 	fprintf(filelist, "symlink\n");
 
 	fclose(filelist);
@@ -61,7 +63,7 @@ DEFINE_TEST(test_option_L_upper)
 	assertTextFileContents("1 block\n", "copy.err");
 
 	failure("Regular -p without -L should preserve symlinks.");
-	assertIsSymlink("copy/symlink", NULL);
+	assertIsSymlink("copy/symlink", NULL, 0);
 
 	r = systemf(CAT " filelist | %s -pd -L copy-L >copy-L.out 2>copy-L.err", testprog);
 	assertEqualInt(r, 0);
@@ -77,13 +79,14 @@ DEFINE_TEST(test_option_L_upper)
 
 	assertMakeDir("unpack", 0755);
 	assertChdir("unpack");
-	r = systemf(CAT " ../archive.out | %s -i >unpack.out 2>unpack.err", testprog);
+	r = systemf(CAT " .." SEP "archive.out | %s -i >unpack.out 2>unpack.err", testprog);
+
 	failure("Error invoking %s -i", testprog);
 	assertEqualInt(r, 0);
 	assertTextFileContents("1 block\n", "unpack.err");
 	assertChdir("..");
 
-	assertIsSymlink("unpack/symlink", NULL);
+	assertIsSymlink("unpack/symlink", NULL, 0);
 
 	r = systemf(CAT " filelist | %s -oL >archive-L.out 2>archive-L.err", testprog);
 	failure("Error invoking %s -oL", testprog);
@@ -92,7 +95,8 @@ DEFINE_TEST(test_option_L_upper)
 
 	assertMakeDir("unpack-L", 0755);
 	assertChdir("unpack-L");
-	r = systemf(CAT " ../archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog);
+	r = systemf(CAT " .." SEP "archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog);
+
 	failure("Error invoking %s -i < archive-L.out", testprog);
 	assertEqualInt(r, 0);
 	assertTextFileContents("1 block\n", "unpack-L.err");

Modified: stable/11/contrib/libarchive/cpio/test/test_option_a.c
==============================================================================
--- stable/11/contrib/libarchive/cpio/test/test_option_a.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/cpio/test/test_option_a.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -71,8 +71,13 @@ test_create(void)
 		 * #ifdef this section out.  Most of the test below is
 		 * still valid. */
 		memset(&times, 0, sizeof(times));
+#if defined(_WIN32) && !defined(CYGWIN)
+		times.actime = 86400;
+		times.modtime = 86400;
+#else
 		times.actime = 1;
 		times.modtime = 3;
+#endif
 		assertEqualInt(0, utime(files[i].name, &times));
 
 		/* Record whatever atime the file ended up with. */

Modified: stable/11/contrib/libarchive/cpio/test/test_option_c.c
==============================================================================
--- stable/11/contrib/libarchive/cpio/test/test_option_c.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/cpio/test/test_option_c.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -85,7 +85,7 @@ DEFINE_TEST(test_option_c)
 
 	/* "symlink" */
 	if (canSymlink()) {
-		assertMakeSymlink("symlink", "file");
+		assertMakeSymlink("symlink", "file", 0);
 		fprintf(filelist, "symlink\n");
 	}
 

Modified: stable/11/contrib/libarchive/libarchive/archive.h
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive.h	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive.h	Tue Jun  4 10:35:54 2019	(r348607)
@@ -338,9 +338,9 @@ typedef const char *archive_passphrase_callback(struct
 #define	ARCHIVE_FORMAT_LHA			0xB0000
 #define	ARCHIVE_FORMAT_CAB			0xC0000
 #define	ARCHIVE_FORMAT_RAR			0xD0000
-#define	ARCHIVE_FORMAT_RAR_V5			(ARCHIVE_FORMAT_RAR | 1)
 #define	ARCHIVE_FORMAT_7ZIP			0xE0000
 #define	ARCHIVE_FORMAT_WARC			0xF0000
+#define	ARCHIVE_FORMAT_RAR_V5			0x100000
 
 /*
  * Codes returned by archive_read_format_capabilities().
@@ -1095,6 +1095,8 @@ __LA_DECL int	archive_match_excluded(struct archive *,
  */
 __LA_DECL int	archive_match_path_excluded(struct archive *,
 		    struct archive_entry *);
+/* Control recursive inclusion of directory content when directory is included. Default on. */
+__LA_DECL int	archive_match_set_inclusion_recursion(struct archive *, int);
 /* Add exclusion pathname pattern. */
 __LA_DECL int	archive_match_exclude_pattern(struct archive *, const char *);
 __LA_DECL int	archive_match_exclude_pattern_w(struct archive *,

Modified: stable/11/contrib/libarchive/libarchive/archive_entry.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_entry.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_entry.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -168,6 +168,7 @@ archive_entry_clear(struct archive_entry *entry)
 	archive_entry_xattr_clear(entry);
 	archive_entry_sparse_clear(entry);
 	free(entry->stat);
+	entry->ae_symlink_type = AE_SYMLINK_TYPE_UNDEFINED;
 	memset(entry, 0, sizeof(*entry));
 	return entry;
 }
@@ -202,6 +203,9 @@ archive_entry_clone(struct archive_entry *entry)
 	entry2->ae_set = entry->ae_set;
 	archive_mstring_copy(&entry2->ae_uname, &entry->ae_uname);
 
+	/* Copy symlink type */
+	entry2->ae_symlink_type = entry->ae_symlink_type;
+
 	/* Copy encryption status */
 	entry2->encryption = entry->encryption;
 	
@@ -253,6 +257,7 @@ archive_entry_new2(struct archive *a)
 	if (entry == NULL)
 		return (NULL);
 	entry->archive = a;
+	entry->ae_symlink_type = AE_SYMLINK_TYPE_UNDEFINED;
 	return (entry);
 }
 
@@ -675,6 +680,12 @@ archive_entry_symlink(struct archive_entry *entry)
 	return (NULL);
 }
 
+int
+archive_entry_symlink_type(struct archive_entry *entry)
+{
+	return (entry->ae_symlink_type);
+}
+
 const char *
 archive_entry_symlink_utf8(struct archive_entry *entry)
 {
@@ -1246,6 +1257,12 @@ archive_entry_set_symlink(struct archive_entry *entry,
 }
 
 void
+archive_entry_set_symlink_type(struct archive_entry *entry, int type)
+{
+	entry->ae_symlink_type = type;
+}
+
+void
 archive_entry_set_symlink_utf8(struct archive_entry *entry, const char *linkname)
 {
 	archive_mstring_copy_utf8(&entry->ae_symlink, linkname);
@@ -1749,6 +1766,10 @@ static const struct flag {
 	{ "nohidden",	L"nohidden",		UF_HIDDEN,	0},
 	{ "nouhidden",	L"nouhidden",		UF_HIDDEN,	0},
 #endif
+#ifdef FILE_ATTRIBUTE_HIDDEN
+	{ "nohidden",	L"nohidden",	FILE_ATTRIBUTE_HIDDEN,	0},
+	{ "nouhidden",	L"nouhidden",	FILE_ATTRIBUTE_HIDDEN,	0},
+#endif
 #ifdef UF_OFFLINE
 	{ "nooffline",	L"nooffline",		UF_OFFLINE,	0},
 	{ "nouoffline",	L"nouoffline",		UF_OFFLINE,	0},
@@ -1758,6 +1779,11 @@ static const struct flag {
 	{ "nourdonly",	L"nourdonly",		UF_READONLY,	0},
 	{ "noreadonly",	L"noreadonly",		UF_READONLY,	0},
 #endif
+#ifdef FILE_ATTRIBUTE_READONLY
+	{ "nordonly",	L"nordonly",	FILE_ATTRIBUTE_READONLY,	0},
+	{ "nourdonly",	L"nourdonly",	FILE_ATTRIBUTE_READONLY,	0},
+	{ "noreadonly",	L"noreadonly",	FILE_ATTRIBUTE_READONLY,	0},
+#endif
 #ifdef UF_SPARSE
 	{ "nosparse",	L"nosparse",		UF_SPARSE,	0},
 	{ "nousparse",	L"nousparse",		UF_SPARSE,	0},
@@ -1769,6 +1795,10 @@ static const struct flag {
 #ifdef UF_SYSTEM
 	{ "nosystem",	L"nosystem",		UF_SYSTEM,	0},
 	{ "nousystem",	L"nousystem",		UF_SYSTEM,	0},
+#endif
+#ifdef FILE_ATTRIBUTE_SYSTEM
+	{ "nosystem",	L"nosystem",	FILE_ATTRIBUTE_SYSTEM,	0},
+	{ "nousystem",	L"nousystem",	FILE_ATTRIBUTE_SYSTEM,	0},
 #endif
 #if defined(FS_UNRM_FL)		/* 'u' */
 	{ "noundel",	L"noundel",		FS_UNRM_FL,	0},

Modified: stable/11/contrib/libarchive/libarchive/archive_entry.h
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_entry.h	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_entry.h	Tue Jun  4 10:35:54 2019	(r348607)
@@ -191,6 +191,13 @@ struct archive_entry;
 #define AE_IFIFO	((__LA_MODE_T)0010000)
 
 /*
+ * Symlink types
+ */
+#define AE_SYMLINK_TYPE_UNDEFINED	0
+#define AE_SYMLINK_TYPE_FILE		1
+#define AE_SYMLINK_TYPE_DIRECTORY	2
+
+/*
  * Basic object manipulation
  */
 
@@ -275,6 +282,7 @@ __LA_DECL int		 archive_entry_size_is_set(struct archi
 __LA_DECL const char	*archive_entry_strmode(struct archive_entry *);
 __LA_DECL const char	*archive_entry_symlink(struct archive_entry *);
 __LA_DECL const char	*archive_entry_symlink_utf8(struct archive_entry *);
+__LA_DECL int		 archive_entry_symlink_type(struct archive_entry *);
 __LA_DECL const wchar_t	*archive_entry_symlink_w(struct archive_entry *);
 __LA_DECL la_int64_t	 archive_entry_uid(struct archive_entry *);
 __LA_DECL const char	*archive_entry_uname(struct archive_entry *);
@@ -350,6 +358,7 @@ __LA_DECL void	archive_entry_unset_size(struct archive
 __LA_DECL void	archive_entry_copy_sourcepath(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_sourcepath_w(struct archive_entry *, const wchar_t *);
 __LA_DECL void	archive_entry_set_symlink(struct archive_entry *, const char *);
+__LA_DECL void	archive_entry_set_symlink_type(struct archive_entry *, int);
 __LA_DECL void	archive_entry_set_symlink_utf8(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_symlink(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *);
@@ -692,7 +701,6 @@ __LA_DECL void archive_entry_linkify(struct archive_en
     struct archive_entry **, struct archive_entry **);
 __LA_DECL struct archive_entry *archive_entry_partial_links(
     struct archive_entry_linkresolver *res, unsigned int *links);
-
 #ifdef __cplusplus
 }
 #endif

Copied: stable/11/contrib/libarchive/libarchive/archive_entry_misc.3 (from r347990, head/contrib/libarchive/libarchive/archive_entry_misc.3)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/contrib/libarchive/libarchive/archive_entry_misc.3	Tue Jun  4 10:35:54 2019	(r348607, copy of r347990, head/contrib/libarchive/libarchive/archive_entry_misc.3)
@@ -0,0 +1,62 @@
+.\" 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+.\"
+.Dd April 15, 2019
+.Dt ARCHIVE_ENTRY_MISC 3
+.Os
+.Sh NAME
+.Nm archive_entry_symlink_type ,
+.Nm archive_entry_set_symlink_type
+.Nd miscellaneous functions for manipulating properties of archive_entry.
+.Sh LIBRARY
+Streaming Archive Library (libarchive, -larchive)
+.Sh SYNOPSIS
+.In archive_entry.h
+.Ft int
+.Fn archive_entry_symlink_type "struct archive_entry *a"
+.Ft void
+.Fn archive_entry_set_symlink_type "struct archive_entry *a" "int"
+.Sh DESCRIPTION
+The function
+.Fn archive_entry_symlink_type
+returns and the function
+.Fn archive_entry_set_symlink_type
+sets the type of the symbolic link stored in an archive entry. These functions
+have special meaning on operating systems that support multiple symbolic link
+types (e.g. Microsoft Windows).
+.Pp
+Supported values are:
+.Bl -tag -width "AE_SYMLINK_TYPE_DIRECTORY" -compact
+.It AE_SYMLINK_TYPE_UNDEFINED
+Symbolic link target type is not defined (default on unix systems)
+.It AE_SYMLINK_TYPE_FILE
+Symbolic link points to a file
+.It AE_SYMLINK_TYPE_DIRECTORY
+Symbolic link points to a directory
+.El
+.Sh SEE ALSO
+.Xr archive_entry 3 ,
+.Xr archive_entry_paths 3 ,
+.Xr archive_entry_stat 3 ,
+.Xr libarchive 3

Modified: stable/11/contrib/libarchive/libarchive/archive_entry_private.h
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_entry_private.h	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_entry_private.h	Tue Jun  4 10:35:54 2019	(r348607)
@@ -176,6 +176,9 @@ struct archive_entry {
 
 	/* Miscellaneous. */
 	char		 strmode[12];
+
+	/* Symlink type support */
+	int ae_symlink_type;
 };
 
 #endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */

Modified: stable/11/contrib/libarchive/libarchive/archive_hmac.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_hmac.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_hmac.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -83,6 +83,7 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
 static int
 __hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
 {
+#pragma GCC diagnostic ignored "-Wcast-qual"
 	BCRYPT_ALG_HANDLE hAlg;
 	BCRYPT_HASH_HANDLE hHash;
 	DWORD hash_len;

Modified: stable/11/contrib/libarchive/libarchive/archive_match.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_match.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_match.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -93,6 +93,9 @@ struct archive_match {
 	/* exclusion/inclusion set flag. */
 	int			 setflag;
 
+	/* Recursively include directory content? */
+	int			 recursive_include;
+
 	/*
 	 * Matching filename patterns.
 	 */
@@ -223,6 +226,7 @@ archive_match_new(void)
 		return (NULL);
 	a->archive.magic = ARCHIVE_MATCH_MAGIC;
 	a->archive.state = ARCHIVE_STATE_NEW;
+	a->recursive_include = 1;
 	match_list_init(&(a->inclusions));
 	match_list_init(&(a->exclusions));
 	__archive_rb_tree_init(&(a->exclusion_tree), &rb_ops_mbs);
@@ -471,6 +475,28 @@ archive_match_path_excluded(struct archive *_a,
 }
 
 /*
+ * When recursive inclusion of directory content is enabled,
+ * an inclusion pattern that matches a directory will also
+ * include everything beneath that directory. Enabled by default.
+ *
+ * For compatibility with GNU tar, exclusion patterns always
+ * match if a subset of the full patch matches (i.e., they are
+ * are not rooted at the beginning of the path) and thus there
+ * is no corresponding non-recursive exclusion mode.
+ */
+int
+archive_match_set_inclusion_recursion(struct archive *_a, int enabled)
+{
+	struct archive_match *a;
+
+	archive_check_magic(_a, ARCHIVE_MATCH_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_match_set_inclusion_recursion");
+	a = (struct archive_match *)_a;
+	a->recursive_include = enabled;
+	return (ARCHIVE_OK);
+}
+
+/*
  * Utility functions to get statistic information for inclusion patterns.
  */
 int
@@ -781,7 +807,10 @@ static int
 match_path_inclusion(struct archive_match *a, struct match *m,
     int mbs, const void *pn)
 {
-	int flag = PATHMATCH_NO_ANCHOR_END;
+	/* Recursive operation requires only a prefix match. */
+	int flag = a->recursive_include ?
+		PATHMATCH_NO_ANCHOR_END :
+		0;
 	int r;
 
 	if (mbs) {
@@ -1232,7 +1261,7 @@ set_timefilter_pathname_mbs(struct archive_match *a, i
 		archive_set_error(&(a->archive), EINVAL, "pathname is empty");
 		return (ARCHIVE_FAILED);
 	}
-	if (stat(path, &st) != 0) {
+	if (la_stat(path, &st) != 0) {
 		archive_set_error(&(a->archive), errno, "Failed to stat()");
 		return (ARCHIVE_FAILED);
 	}

Modified: stable/11/contrib/libarchive/libarchive/archive_platform.h
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_platform.h	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_platform.h	Tue Jun  4 10:35:54 2019	(r348607)
@@ -69,6 +69,8 @@
  * either Windows or Posix APIs. */
 #if (defined(__WIN32__) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__)
 #include "archive_windows.h"
+#else
+#define la_stat(path,stref)		stat(path,stref)
 #endif
 
 /*

Modified: stable/11/contrib/libarchive/libarchive/archive_read.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_read.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -611,6 +611,15 @@ choose_filters(struct archive_read *a)
 	return (ARCHIVE_FATAL);
 }
 
+int
+__archive_read_header(struct archive_read *a, struct archive_entry *entry)
+{
+	if (a->filter->read_header)
+		return a->filter->read_header(a->filter, entry);
+	else
+		return (ARCHIVE_OK);
+}
+
 /*
  * Read header of next entry.
  */

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	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -191,7 +191,7 @@ archive_read_disk_entry_from_file(struct archive *_a,
 				}
 			} else
 #endif
-			if (stat(path, &s) != 0) {
+			if (la_stat(path, &s) != 0) {
 				archive_set_error(&a->archive, errno,
 				    "Can't stat %s", path);
 				return (ARCHIVE_FAILED);

Modified: stable/11/contrib/libarchive/libarchive/archive_read_disk_posix.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_disk_posix.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_read_disk_posix.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -909,7 +909,7 @@ next_entry(struct archive_read_disk *a, struct tree *t
 			    }
 			}
 			break;
-		}	
+		}
 	} while (lst == NULL);
 
 #ifdef __APPLE__
@@ -1295,10 +1295,23 @@ archive_read_disk_descend(struct archive *_a)
 	if (t->visit_type != TREE_REGULAR || !t->descend)
 		return (ARCHIVE_OK);
 
+	/*
+	 * We must not treat the initial specified path as a physical dir,
+	 * because if we do then we will try and ascend out of it by opening
+	 * ".." which is (a) wrong and (b) causes spurious permissions errors
+	 * if ".." is not readable by us. Instead, treat it as if it were a
+	 * symlink. (This uses an extra fd, but it can only happen once at the
+	 * top level of a traverse.) But we can't necessarily assume t->st is
+	 * valid here (though t->lst is), which complicates the logic a
+	 * little.
+	 */
 	if (tree_current_is_physical_dir(t)) {
 		tree_push(t, t->basename, t->current_filesystem_id,
 		    t->lst.st_dev, t->lst.st_ino, &t->restore_time);
-		t->stack->flags |= isDir;
+		if (t->stack->parent->parent != NULL)
+			t->stack->flags |= isDir;
+		else
+			t->stack->flags |= isDirLink;
 	} else if (tree_current_is_dir(t)) {
 		tree_push(t, t->basename, t->current_filesystem_id,
 		    t->st.st_dev, t->st.st_ino, &t->restore_time);
@@ -2151,6 +2164,17 @@ tree_open(const char *path, int symlink_mode, int rest
 static struct tree *
 tree_reopen(struct tree *t, const char *path, int restore_time)
 {
+#if defined(O_PATH)
+	/* Linux */
+	const int o_flag = O_PATH;
+#elif defined(O_SEARCH)
+	/* SunOS */
+	const int o_flag = O_SEARCH;
+#elif defined(O_EXEC)
+	/* FreeBSD */
+	const int o_flag = O_EXEC;
+#endif
+
 	t->flags = (restore_time != 0)?needsRestoreTimes:0;
 	t->flags |= onInitialDir;
 	t->visit_type = 0;
@@ -2172,6 +2196,15 @@ tree_reopen(struct tree *t, const char *path, int rest
 	t->stack->flags = needsFirstVisit;
 	t->maxOpenCount = t->openCount = 1;
 	t->initial_dir_fd = open(".", O_RDONLY | O_CLOEXEC);
+#if defined(O_PATH) || defined(O_SEARCH) || defined(O_EXEC)
+	/*
+	 * Most likely reason to fail opening "." is that it's not readable,
+	 * so try again for execute. The consequences of not opening this are
+	 * unhelpful and unnecessary errors later.
+	 */
+	if (t->initial_dir_fd < 0)
+		t->initial_dir_fd = open(".", o_flag | O_CLOEXEC);
+#endif
 	__archive_ensure_cloexec_flag(t->initial_dir_fd);
 	t->working_dir_fd = tree_dup(t->initial_dir_fd);
 	return (t);
@@ -2479,7 +2512,7 @@ tree_current_stat(struct tree *t)
 #else
 		if (tree_enter_working_dir(t) != 0)
 			return NULL;
-		if (stat(tree_current_access_path(t), &t->st) != 0)
+		if (la_stat(tree_current_access_path(t), &t->st) != 0)
 #endif
 			return NULL;
 		t->flags |= hasStat;

Modified: stable/11/contrib/libarchive/libarchive/archive_read_private.h
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_private.h	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_read_private.h	Tue Jun  4 10:35:54 2019	(r348607)
@@ -98,6 +98,8 @@ struct archive_read_filter {
 	int (*close)(struct archive_read_filter *self);
 	/* Function that handles switching from reading one block to the next/prev */
 	int (*sswitch)(struct archive_read_filter *self, unsigned int iindex);
+	/* Read any header metadata if available. */
+	int (*read_header)(struct archive_read_filter *self, struct archive_entry *entry);
 	/* My private data. */
 	void *data;
 
@@ -250,6 +252,7 @@ int64_t	__archive_read_seek(struct archive_read*, int6
 int64_t	__archive_read_filter_seek(struct archive_read_filter *, int64_t, int);
 int64_t	__archive_read_consume(struct archive_read *, int64_t);
 int64_t	__archive_read_filter_consume(struct archive_read_filter *, int64_t);
+int __archive_read_header(struct archive_read *, struct archive_entry *);
 int __archive_read_program(struct archive_read_filter *, const char *);
 void __archive_read_free_filters(struct archive_read *);
 struct archive_read_extract *__archive_read_get_extract(struct archive_read *);

Modified: stable/11/contrib/libarchive/libarchive/archive_read_set_format.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_set_format.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_read_set_format.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -73,6 +73,9 @@ archive_read_set_format(struct archive *_a, int code)
     case ARCHIVE_FORMAT_RAR:
       strcpy(str, "rar");
       break;
+    case ARCHIVE_FORMAT_RAR_V5:
+      strcpy(str, "rar5");
+      break;
     case ARCHIVE_FORMAT_TAR:
       strcpy(str, "tar");
       break;

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_filter_gzip.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_filter_gzip.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_filter_gzip.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -37,6 +37,9 @@ __FBSDID("$FreeBSD$");
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -45,6 +48,8 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "archive.h"
+#include "archive_entry.h"
+#include "archive_endian.h"
 #include "archive_private.h"
 #include "archive_read_private.h"
 
@@ -56,6 +61,8 @@ struct private_data {
 	size_t		 out_block_size;
 	int64_t		 total_out;
 	unsigned long	 crc;
+	uint32_t	 mtime;
+	char		*name;
 	char		 eof; /* True = found end of compressed data. */
 };
 
@@ -123,7 +130,8 @@ archive_read_support_filter_gzip(struct archive *_a)
  * count of bits verified, suitable for use by bidder.
  */
 static ssize_t
-peek_at_header(struct archive_read_filter *filter, int *pbits)
+peek_at_header(struct archive_read_filter *filter, int *pbits,
+	       struct private_data *state)
 {
 	const unsigned char *p;
 	ssize_t avail, len;
@@ -144,7 +152,9 @@ peek_at_header(struct archive_read_filter *filter, int
 		return (0);
 	bits += 3;
 	header_flags = p[3];
-	/* Bytes 4-7 are mod time. */
+	/* Bytes 4-7 are mod time in little endian. */
+	if (state)
+		state->mtime = archive_le32dec(p + 4);
 	/* Byte 8 is deflate flags. */
 	/* XXXX TODO: return deflate flags back to consume_header for use
 	   in initializing the decompressor. */
@@ -161,6 +171,7 @@ peek_at_header(struct archive_read_filter *filter, int
 
 	/* Null-terminated optional filename. */
 	if (header_flags & 8) {
+		ssize_t file_start = len;
 		do {
 			++len;
 			if (avail < len)
@@ -169,6 +180,12 @@ peek_at_header(struct archive_read_filter *filter, int
 			if (p == NULL)
 				return (0);
 		} while (p[len - 1] != 0);
+
+		if (state) {
+			/* Reset the name in case of repeat header reads. */
+			free(state->name);
+			state->name = strdup((const char *)&p[file_start]);
+		}
 	}
 
 	/* Null-terminated optional comment. */
@@ -214,12 +231,29 @@ gzip_bidder_bid(struct archive_read_filter_bidder *sel
 
 	(void)self; /* UNUSED */
 
-	if (peek_at_header(filter, &bits_checked))
+	if (peek_at_header(filter, &bits_checked, NULL))
 		return (bits_checked);
 	return (0);
 }
 
+static int
+gzip_read_header(struct archive_read_filter *self, struct archive_entry *entry)
+{
+	struct private_data *state;
 
+	state = (struct private_data *)self->data;
+
+	/* A mtime of 0 is considered invalid/missing. */
+	if (state->mtime != 0)
+		archive_entry_set_mtime(entry, state->mtime, 0);
+
+	/* If the name is available, extract it. */
+	if (state->name)
+		archive_entry_set_pathname(entry, state->name);
+
+	return (ARCHIVE_OK);
+}
+
 #ifndef HAVE_ZLIB_H
 
 /*
@@ -272,6 +306,7 @@ gzip_bidder_init(struct archive_read_filter *self)
 	self->read = gzip_filter_read;
 	self->skip = NULL; /* not supported */
 	self->close = gzip_filter_close;
+	self->read_header = gzip_read_header;
 
 	state->in_stream = 0; /* We're not actually within a stream yet. */
 
@@ -289,7 +324,7 @@ consume_header(struct archive_read_filter *self)
 	state = (struct private_data *)self->data;
 
 	/* If this is a real header, consume it. */
-	len = peek_at_header(self->upstream, NULL);
+	len = peek_at_header(self->upstream, NULL, state);
 	if (len == 0)
 		return (ARCHIVE_EOF);
 	__archive_read_filter_consume(self->upstream, len);
@@ -374,7 +409,7 @@ gzip_filter_read(struct archive_read_filter *self, con
 {
 	struct private_data *state;
 	size_t decompressed;
-	ssize_t avail_in;
+	ssize_t avail_in, max_in;
 	int ret;
 
 	state = (struct private_data *)self->data;
@@ -408,6 +443,12 @@ gzip_filter_read(struct archive_read_filter *self, con
 			    "truncated gzip input");
 			return (ARCHIVE_FATAL);
 		}
+		if (UINT_MAX >= SSIZE_MAX)
+			max_in = SSIZE_MAX;
+		else
+			max_in = UINT_MAX;
+		if (avail_in > max_in)
+			avail_in = max_in;
 		state->stream.avail_in = (uInt)avail_in;
 
 		/* Decompress and consume some of that data. */
@@ -469,6 +510,7 @@ gzip_filter_close(struct archive_read_filter *self)
 		}
 	}
 
+	free(state->name);
 	free(state->out_block);
 	free(state);
 	return (ret);

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_cab.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_format_cab.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_cab.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -1509,8 +1509,8 @@ cab_read_ahead_cfdata_deflate(struct archive_read *a, 
 			}
 			if (mszip == 1 && cab->stream.next_in[0] != 0x4b)
 				goto nomszip;
-			else if (cab->stream.next_in[0] != 0x43 ||
-			    cab->stream.next_in[1] != 0x4b)
+			else if (mszip == 2 && (cab->stream.next_in[0] != 0x43 ||
+			    cab->stream.next_in[1] != 0x4b))
 				goto nomszip;
 			cab->stream.next_in += mszip;
 			cab->stream.avail_in -= mszip;

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -45,6 +45,9 @@ __FBSDID("$FreeBSD$");
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
 
 #include "archive.h"
 #include "archive_entry.h"
@@ -1011,7 +1014,7 @@ read_mtree(struct archive_read *a, struct mtree *mtree
 {
 	ssize_t len;
 	uintmax_t counter;
-	char *p;
+	char *p, *s;
 	struct mtree_option *global;
 	struct mtree_entry *last_entry;
 	int r, is_form_d;
@@ -1025,6 +1028,7 @@ read_mtree(struct archive_read *a, struct mtree *mtree
 	(void)detect_form(a, &is_form_d);
 
 	for (counter = 1; ; ++counter) {
+		r = ARCHIVE_OK;
 		len = readline(a, mtree, &p, 65536);
 		if (len == 0) {
 			mtree->this_entry = mtree->entries;
@@ -1045,6 +1049,15 @@ read_mtree(struct archive_read *a, struct mtree *mtree
 			continue;
 		if (*p == '\r' || *p == '\n' || *p == '\0')
 			continue;
+		/* Non-printable characters are not allowed */
+		for (s = p;s < p + len - 1; s++) {
+			if (!isprint(*s)) {
+				r = ARCHIVE_FATAL;
+				break;
+			}
+		}
+		if (r != ARCHIVE_OK)
+			break;
 		if (*p != '/') {
 			r = process_add_entry(a, mtree, &global, p, len,
 			    &last_entry, is_form_d);

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_rar.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_format_rar.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_rar.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -1024,8 +1024,10 @@ archive_read_format_rar_read_data(struct archive_read 
   case COMPRESS_METHOD_GOOD:
   case COMPRESS_METHOD_BEST:
     ret = read_data_compressed(a, buff, size, offset);
-    if (ret != ARCHIVE_OK && ret != ARCHIVE_WARN)
+    if (ret != ARCHIVE_OK && ret != ARCHIVE_WARN) {
       __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context);
+      rar->start_new_table = 1;
+    }
     break;
 
   default:

Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_rar5.c
==============================================================================
--- stable/11/contrib/libarchive/libarchive/archive_read_support_format_rar5.c	Tue Jun  4 10:28:50 2019	(r348606)
+++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_rar5.c	Tue Jun  4 10:35:54 2019	(r348607)
@@ -33,6 +33,9 @@
 #ifdef HAVE_ZLIB_H
 #include <zlib.h> /* crc32 */
 #endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
 
 #include "archive.h"
 #ifndef HAVE_ZLIB_H
@@ -78,230 +81,275 @@
 
 static unsigned char rar5_signature[] = { 243, 192, 211, 128, 187, 166, 160, 161 };
 static const ssize_t rar5_signature_size = sizeof(rar5_signature);
-/* static const size_t g_unpack_buf_chunk_size = 1024; */
 static const size_t g_unpack_window_size = 0x20000;
 
+/* These could have been static const's, but they aren't, because of
+ * Visual Studio. */
+#define MAX_NAME_IN_CHARS 2048
+#define MAX_NAME_IN_BYTES (4 * MAX_NAME_IN_CHARS)
+
 struct file_header {
-    ssize_t bytes_remaining;
-    ssize_t unpacked_size;
-    int64_t last_offset;         /* Used in sanity checks. */
-    int64_t last_size;           /* Used in sanity checks. */
+	ssize_t bytes_remaining;
+	ssize_t unpacked_size;
+	int64_t last_offset;         /* Used in sanity checks. */
+	int64_t last_size;           /* Used in sanity checks. */
 
-    uint8_t solid : 1;           /* Is this a solid stream? */
-    uint8_t service : 1;         /* Is this file a service data? */
-    uint8_t eof : 1;             /* Did we finish unpacking the file? */
+	uint8_t solid : 1;           /* Is this a solid stream? */
+	uint8_t service : 1;         /* Is this file a service data? */
+	uint8_t eof : 1;             /* Did we finish unpacking the file? */
+	uint8_t dir : 1;             /* Is this file entry a directory? */
 
-    /* Optional time fields. */
-    uint64_t e_mtime;
-    uint64_t e_ctime;
-    uint64_t e_atime;
-    uint32_t e_unix_ns;
+	/* Optional time fields. */
+	uint64_t e_mtime;
+	uint64_t e_ctime;
+	uint64_t e_atime;
+	uint32_t e_unix_ns;
 
-    /* Optional hash fields. */
-    uint32_t stored_crc32;
-    uint32_t calculated_crc32;
-    uint8_t blake2sp[32];
-    blake2sp_state b2state;
-    char has_blake2;
+	/* Optional hash fields. */
+	uint32_t stored_crc32;
+	uint32_t calculated_crc32;
+	uint8_t blake2sp[32];
+	blake2sp_state b2state;
+	char has_blake2;
+
+	/* Optional redir fields */
+	uint64_t redir_type;
+	uint64_t redir_flags;
 };
 
+enum EXTRA {
+	EX_CRYPT = 0x01,
+	EX_HASH = 0x02,
+	EX_HTIME = 0x03,
+	EX_VERSION = 0x04,
+	EX_REDIR = 0x05,
+	EX_UOWNER = 0x06,
+	EX_SUBDATA = 0x07
+};
+
+#define REDIR_SYMLINK_IS_DIR	1
+
+enum REDIR_TYPE {
+	REDIR_TYPE_NONE = 0,
+	REDIR_TYPE_UNIXSYMLINK = 1,
+	REDIR_TYPE_WINSYMLINK = 2,
+	REDIR_TYPE_JUNCTION = 3,
+	REDIR_TYPE_HARDLINK = 4,
+	REDIR_TYPE_FILECOPY = 5,
+};
+
+#define	OWNER_USER_NAME		0x01
+#define	OWNER_GROUP_NAME	0x02
+#define	OWNER_USER_UID		0x04
+#define	OWNER_GROUP_GID		0x08
+#define	OWNER_MAXNAMELEN	256
+
 enum FILTER_TYPE {
-    FILTER_DELTA = 0,   /* Generic pattern. */
-    FILTER_E8    = 1,   /* Intel x86 code. */
-    FILTER_E8E9  = 2,   /* Intel x86 code. */
-    FILTER_ARM   = 3,   /* ARM code. */
-    FILTER_AUDIO = 4,   /* Audio filter, not used in RARv5. */
-    FILTER_RGB   = 5,   /* Color palette, not used in RARv5. */
-    FILTER_ITANIUM = 6, /* Intel's Itanium, not used in RARv5. */
-    FILTER_PPM   = 7,   /* Predictive pattern matching, not used in RARv5. */
-    FILTER_NONE  = 8,
+	FILTER_DELTA = 0,   /* Generic pattern. */
+	FILTER_E8    = 1,   /* Intel x86 code. */
+	FILTER_E8E9  = 2,   /* Intel x86 code. */
+	FILTER_ARM   = 3,   /* ARM code. */
+	FILTER_AUDIO = 4,   /* Audio filter, not used in RARv5. */
+	FILTER_RGB   = 5,   /* Color palette, not used in RARv5. */
+	FILTER_ITANIUM = 6, /* Intel's Itanium, not used in RARv5. */
+	FILTER_PPM   = 7,   /* Predictive pattern matching, not used in
+			       RARv5. */
+	FILTER_NONE  = 8,
 };
 
 struct filter_info {
-    int type;
-    int channels;
-    int pos_r;
+	int type;
+	int channels;
+	int pos_r;
 
-    int64_t block_start;
-    ssize_t block_length;
-    uint16_t width;
+	int64_t block_start;
+	ssize_t block_length;
+	uint16_t width;
 };
 
 struct data_ready {
-    char used;
-    const uint8_t* buf;
-    size_t size;
-    int64_t offset;
+	char used;
+	const uint8_t* buf;
+	size_t size;
+	int64_t offset;
 };
 
 struct cdeque {
-    uint16_t beg_pos;
-    uint16_t end_pos;
-    uint16_t cap_mask;
-    uint16_t size;
-    size_t* arr;
+	uint16_t beg_pos;
+	uint16_t end_pos;
+	uint16_t cap_mask;
+	uint16_t size;
+	size_t* arr;
 };
 
 struct decode_table {
-    uint32_t size;
-    int32_t decode_len[16];
-    uint32_t decode_pos[16];
-    uint32_t quick_bits;

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



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