svn commit: r368207 - in vendor/libarchive/dist: . .github/workflows build build/ci/github_actions build/cmake build/release libarchive libarchive/test test_utils

Martin Matuska mm at FreeBSD.org
Tue Dec 1 10:36:53 UTC 2020


Author: mm
Date: Tue Dec  1 10:36:46 2020
New Revision: 368207
URL: https://svnweb.freebsd.org/changeset/base/368207

Log:
  Update vendor/libarchive/dist to git 833821f55b1807cac22a63a58b759a7802df2fb7
  
  Libarchive 3.5.0
  
  Relevant vendor changes:
    Issue #1258: add archive_read_support_filter_by_code()
    PR #1347: mtree digest reader support
    Issue #1381: skip hardlinks pointing to itself on extraction
    PR #1387: fix writing of cpio archives with hardlinks without file type
    PR #1388: fix rdev field in cpio format for device nodes
    PR #1389: completed support for UTF-8 encoding conversion
    PR #1405: more formats in archive_read_support_format_by_code()
    PR #1408: fix uninitialized size in rar5_read_data
    PR #1409: system extended attribute support
    PR #1435: support for decompression of symbolic links in zipx archives
    Issue #1456: memory leak after unsuccessful archive_write_open_filename

Added:
  vendor/libarchive/dist/libarchive/archive_read_support_filter_by_code.c   (contents, props changed)
  vendor/libarchive/dist/libarchive/test/test_read_format_zip_7z_lzma.zip.uu
Modified:
  vendor/libarchive/dist/.cirrus.yml
  vendor/libarchive/dist/.github/workflows/ci.yml
  vendor/libarchive/dist/COPYING
  vendor/libarchive/dist/Makefile.am
  vendor/libarchive/dist/NEWS
  vendor/libarchive/dist/build/ci/github_actions/macos.sh
  vendor/libarchive/dist/build/cmake/config.h.in
  vendor/libarchive/dist/build/release/Dockerfile
  vendor/libarchive/dist/build/version
  vendor/libarchive/dist/configure.ac
  vendor/libarchive/dist/libarchive/archive.h
  vendor/libarchive/dist/libarchive/archive_acl.c
  vendor/libarchive/dist/libarchive/archive_check_magic.c
  vendor/libarchive/dist/libarchive/archive_cryptor.c
  vendor/libarchive/dist/libarchive/archive_cryptor_private.h
  vendor/libarchive/dist/libarchive/archive_digest_private.h
  vendor/libarchive/dist/libarchive/archive_entry.c
  vendor/libarchive/dist/libarchive/archive_entry.h
  vendor/libarchive/dist/libarchive/archive_entry_private.h
  vendor/libarchive/dist/libarchive/archive_ppmd7.c
  vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c
  vendor/libarchive/dist/libarchive/archive_read_filter.3
  vendor/libarchive/dist/libarchive/archive_read_set_format.c
  vendor/libarchive/dist/libarchive/archive_read_support_format_by_code.c
  vendor/libarchive/dist/libarchive/archive_read_support_format_cab.c
  vendor/libarchive/dist/libarchive/archive_read_support_format_empty.c
  vendor/libarchive/dist/libarchive/archive_read_support_format_mtree.c
  vendor/libarchive/dist/libarchive/archive_read_support_format_rar.c
  vendor/libarchive/dist/libarchive/archive_read_support_format_rar5.c
  vendor/libarchive/dist/libarchive/archive_read_support_format_warc.c
  vendor/libarchive/dist/libarchive/archive_read_support_format_zip.c
  vendor/libarchive/dist/libarchive/archive_string.c
  vendor/libarchive/dist/libarchive/archive_string.h
  vendor/libarchive/dist/libarchive/archive_util.c
  vendor/libarchive/dist/libarchive/archive_write.c
  vendor/libarchive/dist/libarchive/archive_write_add_filter_xz.c
  vendor/libarchive/dist/libarchive/archive_write_disk_posix.c
  vendor/libarchive/dist/libarchive/archive_write_open.3
  vendor/libarchive/dist/libarchive/archive_write_open_fd.c
  vendor/libarchive/dist/libarchive/archive_write_open_file.c
  vendor/libarchive/dist/libarchive/archive_write_open_filename.c
  vendor/libarchive/dist/libarchive/archive_write_open_memory.c
  vendor/libarchive/dist/libarchive/archive_write_private.h
  vendor/libarchive/dist/libarchive/archive_write_set_format_7zip.c
  vendor/libarchive/dist/libarchive/archive_write_set_format_cpio.c
  vendor/libarchive/dist/libarchive/archive_write_set_format_cpio_newc.c
  vendor/libarchive/dist/libarchive/archive_write_set_format_iso9660.c
  vendor/libarchive/dist/libarchive/archive_write_set_format_mtree.c
  vendor/libarchive/dist/libarchive/archive_write_set_format_xar.c
  vendor/libarchive/dist/libarchive/archive_write_set_format_zip.c
  vendor/libarchive/dist/libarchive/config_freebsd.h
  vendor/libarchive/dist/libarchive/test/test_archive_read_next_header_empty.c
  vendor/libarchive/dist/libarchive/test/test_archive_read_support.c
  vendor/libarchive/dist/libarchive/test/test_archive_string_conversion.c
  vendor/libarchive/dist/libarchive/test/test_entry.c
  vendor/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c
  vendor/libarchive/dist/libarchive/test/test_read_format_mtree.c
  vendor/libarchive/dist/libarchive/test/test_read_format_mtree.mtree.uu
  vendor/libarchive/dist/libarchive/test/test_read_format_raw.c
  vendor/libarchive/dist/libarchive/test/test_read_format_zip.c
  vendor/libarchive/dist/libarchive/test/test_read_set_format.c
  vendor/libarchive/dist/libarchive/test/test_write_disk_secure.c
  vendor/libarchive/dist/libarchive/test/test_write_format_cpio.c
  vendor/libarchive/dist/libarchive/test/test_write_format_warc.c
  vendor/libarchive/dist/test_utils/test_common.h
  vendor/libarchive/dist/test_utils/test_main.c

Modified: vendor/libarchive/dist/.cirrus.yml
==============================================================================
--- vendor/libarchive/dist/.cirrus.yml	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/.cirrus.yml	Tue Dec  1 10:36:46 2020	(r368207)
@@ -12,7 +12,7 @@ FreeBSD_task:
     freebsd_instance:
       image_family: freebsd-12-1
     freebsd_instance:
-      image: freebsd-11-3-stable-amd64-v20190801
+      image_family: freebsd-11-4
   prepare_script:
   - ./build/ci/cirrus_ci/ci.sh prepare
   configure_script:

Modified: vendor/libarchive/dist/.github/workflows/ci.yml
==============================================================================
--- vendor/libarchive/dist/.github/workflows/ci.yml	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/.github/workflows/ci.yml	Tue Dec  1 10:36:46 2020	(r368207)
@@ -43,7 +43,7 @@ jobs:
         path: libarchive.tar.xz
 
   Ubuntu:
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     strategy:
       matrix:
         bs: [autotools, cmake]
@@ -83,7 +83,7 @@ jobs:
         name: libarchive-ubuntu-${{ matrix.bs }}-${{ matrix.crypto }}-${{ github.sha }}
         path: libarchive.tar.xz
   Ubuntu-distcheck:
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     steps:
     - uses: actions/checkout at master
     - name: Install dependencies

Modified: vendor/libarchive/dist/COPYING
==============================================================================
--- vendor/libarchive/dist/COPYING	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/COPYING	Tue Dec  1 10:36:46 2020	(r368207)
@@ -15,7 +15,6 @@ the actual statements in the files are controlling.
 * The following source files are also subject in whole or in part to
   a 3-clause UC Regents copyright; please read the individual source
   files for details:
-   libarchive/archive_entry.c
    libarchive/archive_read_support_filter_compress.c
    libarchive/archive_write_add_filter_compress.c
    libarchive/mtree.5

Modified: vendor/libarchive/dist/Makefile.am
==============================================================================
--- vendor/libarchive/dist/Makefile.am	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/Makefile.am	Tue Dec  1 10:36:46 2020	(r368207)
@@ -158,6 +158,7 @@ libarchive_la_SOURCES= \
 	libarchive/archive_read_set_options.c \
 	libarchive/archive_read_support_filter_all.c \
 	libarchive/archive_read_support_filter_bzip2.c \
+	libarchive/archive_read_support_filter_by_code.c \
 	libarchive/archive_read_support_filter_compress.c \
 	libarchive/archive_read_support_filter_grzip.c \
 	libarchive/archive_read_support_filter_gzip.c \
@@ -897,6 +898,7 @@ libarchive_test_EXTRA_DIST=\
 	libarchive/test/test_read_format_warc.warc.uu \
 	libarchive/test/test_read_format_zip.zip.uu \
 	libarchive/test/test_read_format_zip_7075_utf8_paths.zip.uu \
+	libarchive/test/test_read_format_zip_7z_lzma.zip.uu \
 	libarchive/test/test_read_format_zip_bz2_hang.zip.uu \
 	libarchive/test/test_read_format_zip_bzip2.zipx.uu \
 	libarchive/test/test_read_format_zip_bzip2_multi.zipx.uu \

Modified: vendor/libarchive/dist/NEWS
==============================================================================
--- vendor/libarchive/dist/NEWS	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/NEWS	Tue Dec  1 10:36:46 2020	(r368207)
@@ -1,3 +1,7 @@
+Dec 01, 2020: libarchive 3.5.0 released
+
+Oct 14, 2020: Support for system extended attributes
+
 May 20, 2020: libarchive 3.4.3 released
 
 Apr 30, 2020: Support for pzstd compressed files

Modified: vendor/libarchive/dist/build/ci/github_actions/macos.sh
==============================================================================
--- vendor/libarchive/dist/build/ci/github_actions/macos.sh	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/build/ci/github_actions/macos.sh	Tue Dec  1 10:36:46 2020	(r368207)
@@ -1,9 +1,24 @@
 #!/bin/sh
 if [ "$1" = "prepare" ]
 then
-	set -x -e
+	set -x
+	brew uninstall openssl at 1.0.2t > /dev/null
+	brew uninstall python at 2.7.17 > /dev/null
+	brew untap local/openssl > /dev/null
+	brew untap local/python2 > /dev/null
 	brew update > /dev/null
-	for pkg in autoconf automake libtool pkg-config cmake xz lz4 zstd
+	brew upgrade > /dev/null
+	set -x -e
+	for pkg in \
+		autoconf \
+		automake \
+		libtool \
+		pkg-config \
+		cmake \
+		xz \
+		lz4 \
+		zstd \
+		openssl
 	do
 		brew list $pkg > /dev/null && brew upgrade $pkg || brew install $pkg
 	done

Modified: vendor/libarchive/dist/build/cmake/config.h.in
==============================================================================
--- vendor/libarchive/dist/build/cmake/config.h.in	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/build/cmake/config.h.in	Tue Dec  1 10:36:46 2020	(r368207)
@@ -1,4 +1,5 @@
 /* config.h.  Generated from build/cmake/config.h.in by cmake configure */
+#define __LIBARCHIVE_CONFIG_H_INCLUDED 1
 
 /*
  * Ensure we have C99-style int64_t, etc, all defined.

Modified: vendor/libarchive/dist/build/release/Dockerfile
==============================================================================
--- vendor/libarchive/dist/build/release/Dockerfile	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/build/release/Dockerfile	Tue Dec  1 10:36:46 2020	(r368207)
@@ -1,5 +1,7 @@
-FROM ubuntu:18.04
-RUN apt-get update && apt-get install -y build-essential autoconf automake libtool pkg-config cmake libssl-dev libacl1-dev libbz2-dev liblzma-dev liblz4-dev libzstd-dev lzop groff ghostscript bsdmainutils zip
+FROM ubuntu:20.04
+ENV DEBIAN_FRONTEND=noninteractive
+RUN ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
+RUN apt-get update && apt-get install -y build-essential autoconf automake libtool pkg-config cmake zlib1g-dev libssl-dev libacl1-dev libbz2-dev liblzma-dev liblz4-dev libzstd-dev lzop groff ghostscript bsdmainutils zip
 ADD . $HOME/libarchive/
 ADD "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD" $HOME/libarchive/build/autoconf/config.guess
 ADD "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD" $HOME/libarchive/build/autoconf/config.sub

Modified: vendor/libarchive/dist/build/version
==============================================================================
--- vendor/libarchive/dist/build/version	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/build/version	Tue Dec  1 10:36:46 2020	(r368207)
@@ -1 +1 @@
-3004003
+3005000

Modified: vendor/libarchive/dist/configure.ac
==============================================================================
--- vendor/libarchive/dist/configure.ac	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/configure.ac	Tue Dec  1 10:36:46 2020	(r368207)
@@ -4,8 +4,8 @@ dnl First, define all of the version numbers up front.
 dnl In particular, this allows the version macro to be used in AC_INIT
 
 dnl These first two version numbers are updated automatically on each release.
-m4_define([LIBARCHIVE_VERSION_S],[3.4.3])
-m4_define([LIBARCHIVE_VERSION_N],[3004003])
+m4_define([LIBARCHIVE_VERSION_S],[3.5.0])
+m4_define([LIBARCHIVE_VERSION_N],[3005000])
 
 dnl bsdtar and bsdcpio versioning tracks libarchive
 m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
@@ -47,6 +47,8 @@ ARCHIVE_REVISION=$(( LIBARCHIVE_VERSION_N() % 1000 ))
 ARCHIVE_LIBTOOL_VERSION=$ARCHIVE_INTERFACE:$ARCHIVE_REVISION:$ARCHIVE_MINOR
 
 # Stick the version numbers into config.h
+AC_DEFINE([__LIBARCHIVE_CONFIG_H_INCLUDED], [1],
+	[Internal macro for sanity checks])
 AC_DEFINE([LIBARCHIVE_VERSION_STRING],"LIBARCHIVE_VERSION_S()",
 	[Version number of libarchive])
 AC_DEFINE_UNQUOTED([LIBARCHIVE_VERSION_NUMBER],"LIBARCHIVE_VERSION_N()",
@@ -103,6 +105,7 @@ AC_SUBST(PLATFORMCPPFLAGS)
 
 # Checks for programs.
 AC_PROG_CC
+AC_PROG_CC_C99
 AM_PROG_CC_C_O
 AC_USE_SYSTEM_EXTENSIONS
 AC_LIBTOOL_WIN32_DLL
@@ -244,9 +247,23 @@ AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcp
 # Set up defines needed before including any headers
 case $host in
   *mingw* | *cygwin* | *msys*  )
-  AC_DEFINE([_WIN32_WINNT], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
-  AC_DEFINE([WINVER], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
-  AC_DEFINE([NTDDI_VERSION], 0x05020000, [Define to '0x05020000' for Windows Server 2003 APIs.])
+  AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
+    [[#ifdef _WIN32_WINNT
+     # error _WIN32_WINNT already defined
+     #endif
+    ]],[[;]])
+  ],[
+    AC_DEFINE([_WIN32_WINNT], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
+    AC_DEFINE([NTDDI_VERSION], 0x05020000, [Define to '0x05020000' for Windows Server 2003 APIs.])
+  ])
+  AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
+    [[#ifdef WINVER
+     # error WINVER already defined
+     #endif
+    ]],[[;]])
+  ],[
+    AC_DEFINE([WINVER], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
+  ])
   ;;
 esac
 

Modified: vendor/libarchive/dist/libarchive/archive.h
==============================================================================
--- vendor/libarchive/dist/libarchive/archive.h	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive.h	Tue Dec  1 10:36:46 2020	(r368207)
@@ -36,7 +36,7 @@
  * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
  */
 /* Note: Compiler will complain if this does not match archive_entry.h! */
-#define	ARCHIVE_VERSION_NUMBER 3004003
+#define	ARCHIVE_VERSION_NUMBER 3005000
 
 #include <sys/stat.h>
 #include <stddef.h>  /* for wchar_t */
@@ -155,7 +155,7 @@ __LA_DECL int		archive_version_number(void);
 /*
  * Textual name/version of the library, useful for version displays.
  */
-#define	ARCHIVE_VERSION_ONLY_STRING "3.4.3"
+#define	ARCHIVE_VERSION_ONLY_STRING "3.5.0"
 #define	ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
 __LA_DECL const char *	archive_version_string(void);
 
@@ -246,6 +246,8 @@ typedef int	archive_open_callback(struct archive *, vo
 
 typedef int	archive_close_callback(struct archive *, void *_client_data);
 
+typedef int	archive_free_callback(struct archive *, void *_client_data);
+
 /* Switches from one client data object to the next/prev client data object.
  * This is useful for reading from different data blocks such as a set of files
  * that make up one large file.
@@ -418,6 +420,7 @@ __LA_DECL int archive_read_support_compression_xz(stru
 #endif
 
 __LA_DECL int archive_read_support_filter_all(struct archive *);
+__LA_DECL int archive_read_support_filter_by_code(struct archive *, int);
 __LA_DECL int archive_read_support_filter_bzip2(struct archive *);
 __LA_DECL int archive_read_support_filter_compress(struct archive *);
 __LA_DECL int archive_read_support_filter_gzip(struct archive *);
@@ -817,9 +820,13 @@ __LA_DECL int archive_write_set_format_filter_by_ext(s
 __LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext);
 __LA_DECL int archive_write_zip_set_compression_deflate(struct archive *);
 __LA_DECL int archive_write_zip_set_compression_store(struct archive *);
+/* Deprecated; use archive_write_open2 instead */
 __LA_DECL int archive_write_open(struct archive *, void *,
 		     archive_open_callback *, archive_write_callback *,
 		     archive_close_callback *);
+__LA_DECL int archive_write_open2(struct archive *, void *,
+		     archive_open_callback *, archive_write_callback *,
+		     archive_close_callback *, archive_free_callback *);
 __LA_DECL int archive_write_open_fd(struct archive *, int _fd);
 __LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
 __LA_DECL int archive_write_open_filename_w(struct archive *,

Modified: vendor/libarchive/dist/libarchive/archive_acl.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_acl.c	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_acl.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -595,7 +595,7 @@ archive_acl_text_len(struct archive_acl *acl, int want
 				else
 					length += sizeof(uid_t) * 3 + 1;
 			} else {
-				r = archive_mstring_get_mbs_l(&ap->name, &name,
+				r = archive_mstring_get_mbs_l(a, &ap->name, &name,
 				    &len, sc);
 				if (r != 0)
 					return (0);
@@ -968,7 +968,7 @@ archive_acl_to_text_l(struct archive_acl *acl, ssize_t
 		else
 			prefix = NULL;
 		r = archive_mstring_get_mbs_l(
-		    &ap->name, &name, &len, sc);
+		    NULL, &ap->name, &name, &len, sc);
 		if (r != 0) {
 			free(s);
 			return (NULL);
@@ -1402,14 +1402,14 @@ isint_w(const wchar_t *start, const wchar_t *end, int 
 	if (start >= end)
 		return (0);
 	while (start < end) {
-		if (*start < '0' || *start > '9')
+		if (*start < L'0' || *start > L'9')
 			return (0);
 		if (n > (INT_MAX / 10) ||
-		    (n == INT_MAX / 10 && (*start - '0') > INT_MAX % 10)) {
+		    (n == INT_MAX / 10 && (*start - L'0') > INT_MAX % 10)) {
 			n = INT_MAX;
 		} else {
 			n *= 10;
-			n += *start - '0';
+			n += *start - L'0';
 		}
 		start++;
 	}

Modified: vendor/libarchive/dist/libarchive/archive_check_magic.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_check_magic.c	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_check_magic.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -54,7 +54,7 @@ errmsg(const char *m)
 	ssize_t written;
 
 	while (s > 0) {
-		written = write(2, m, strlen(m));
+		written = write(2, m, s);
 		if (written <= 0)
 			return;
 		m += written;

Modified: vendor/libarchive/dist/libarchive/archive_cryptor.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_cryptor.c	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_cryptor.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -347,8 +347,31 @@ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *k
 static int
 aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
 {
+#if NETTLE_VERSION_MAJOR < 3
 	aes_set_encrypt_key(&ctx->ctx, ctx->key_len, ctx->key);
 	aes_encrypt(&ctx->ctx, AES_BLOCK_SIZE, ctx->encr_buf, ctx->nonce);
+#else
+	switch(ctx->key_len) {
+	case AES128_KEY_SIZE:
+		aes128_set_encrypt_key(&ctx->ctx.c128, ctx->key);
+		aes128_encrypt(&ctx->ctx.c128, AES_BLOCK_SIZE, ctx->encr_buf,
+		    ctx->nonce);
+		break;
+	case AES192_KEY_SIZE:
+		aes192_set_encrypt_key(&ctx->ctx.c192, ctx->key);
+		aes192_encrypt(&ctx->ctx.c192, AES_BLOCK_SIZE, ctx->encr_buf,
+		    ctx->nonce);
+		break;
+	case AES256_KEY_SIZE:
+		aes256_set_encrypt_key(&ctx->ctx.c256, ctx->key);
+		aes256_encrypt(&ctx->ctx.c256, AES_BLOCK_SIZE, ctx->encr_buf,
+		    ctx->nonce);
+		break;
+	default:
+		return -1;
+		break;
+	}
+#endif
 	return 0;
 }
 

Modified: vendor/libarchive/dist/libarchive/archive_cryptor_private.h
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_cryptor_private.h	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_cryptor_private.h	Tue Dec  1 10:36:46 2020	(r368207)
@@ -104,9 +104,18 @@ typedef struct {
 #include <nettle/pbkdf2.h>
 #endif
 #include <nettle/aes.h>
+#include <nettle/version.h>
 
 typedef struct {
+#if NETTLE_VERSION_MAJOR < 3
 	struct aes_ctx	ctx;
+#else
+	union {
+		struct aes128_ctx c128;
+		struct aes192_ctx c192;
+		struct aes256_ctx c256;
+	}		ctx;
+#endif
 	uint8_t		key[AES_MAX_KEY_SIZE];
 	unsigned	key_len;
 	uint8_t		nonce[AES_BLOCK_SIZE];

Modified: vendor/libarchive/dist/libarchive/archive_digest_private.h
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_digest_private.h	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_digest_private.h	Tue Dec  1 10:36:46 2020	(r368207)
@@ -30,6 +30,10 @@
 #ifndef __LIBARCHIVE_BUILD
 #error This header is only to be used internally to libarchive.
 #endif
+#ifndef __LIBARCHIVE_CONFIG_H_INCLUDED
+#error "Should have include config.h first!"
+#endif
+
 /*
  * Crypto support in various Operating Systems:
  *

Modified: vendor/libarchive/dist/libarchive/archive_entry.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_entry.c	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_entry.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -208,6 +208,19 @@ archive_entry_clone(struct archive_entry *entry)
 
 	/* Copy encryption status */
 	entry2->encryption = entry->encryption;
+
+	/* Copy digests */
+#define copy_digest(_e2, _e, _t) \
+	memcpy(_e2->digest._t, _e->digest._t, sizeof(_e2->digest._t))
+
+	copy_digest(entry2, entry, md5);
+	copy_digest(entry2, entry, rmd160);
+	copy_digest(entry2, entry, sha1);
+	copy_digest(entry2, entry, sha256);
+	copy_digest(entry2, entry, sha384);
+	copy_digest(entry2, entry, sha512);
+
+#undef copy_digest
 	
 	/* Copy ACL data over. */
 	archive_acl_copy(&entry2->acl, &entry->acl);
@@ -450,7 +463,7 @@ int
 _archive_entry_gname_l(struct archive_entry *entry,
     const char **p, size_t *len, struct archive_string_conv *sc)
 {
-	return (archive_mstring_get_mbs_l(&entry->ae_gname, p, len, sc));
+	return (archive_mstring_get_mbs_l(entry->archive, &entry->ae_gname, p, len, sc));
 }
 
 const char *
@@ -504,7 +517,7 @@ _archive_entry_hardlink_l(struct archive_entry *entry,
 		*len = 0;
 		return (0);
 	}
-	return (archive_mstring_get_mbs_l(&entry->ae_hardlink, p, len, sc));
+	return (archive_mstring_get_mbs_l(entry->archive, &entry->ae_hardlink, p, len, sc));
 }
 
 la_int64_t
@@ -595,7 +608,7 @@ int
 _archive_entry_pathname_l(struct archive_entry *entry,
     const char **p, size_t *len, struct archive_string_conv *sc)
 {
-	return (archive_mstring_get_mbs_l(&entry->ae_pathname, p, len, sc));
+	return (archive_mstring_get_mbs_l(entry->archive, &entry->ae_pathname, p, len, sc));
 }
 
 __LA_MODE_T
@@ -723,7 +736,7 @@ _archive_entry_symlink_l(struct archive_entry *entry,
 		*len = 0;
 		return (0);
 	}
-	return (archive_mstring_get_mbs_l( &entry->ae_symlink, p, len, sc));
+	return (archive_mstring_get_mbs_l(entry->archive, &entry->ae_symlink, p, len, sc));
 }
 
 la_int64_t
@@ -769,7 +782,7 @@ int
 _archive_entry_uname_l(struct archive_entry *entry,
     const char **p, size_t *len, struct archive_string_conv *sc)
 {
-	return (archive_mstring_get_mbs_l(&entry->ae_uname, p, len, sc));
+	return (archive_mstring_get_mbs_l(entry->archive, &entry->ae_uname, p, len, sc));
 }
 
 int
@@ -1414,6 +1427,62 @@ archive_entry_copy_mac_metadata(struct archive_entry *
       abort();
     memcpy(entry->mac_metadata, p, s);
   }
+}
+
+/* Digest handling */
+const unsigned char *
+archive_entry_digest(struct archive_entry *entry, int type)
+{
+	switch (type) {
+	case ARCHIVE_ENTRY_DIGEST_MD5:
+		return entry->digest.md5;
+	case ARCHIVE_ENTRY_DIGEST_RMD160:
+		return entry->digest.rmd160;
+	case ARCHIVE_ENTRY_DIGEST_SHA1:
+		return entry->digest.sha1;
+	case ARCHIVE_ENTRY_DIGEST_SHA256:
+		return entry->digest.sha256;
+	case ARCHIVE_ENTRY_DIGEST_SHA384:
+		return entry->digest.sha384;
+	case ARCHIVE_ENTRY_DIGEST_SHA512:
+		return entry->digest.sha512;
+	default:
+		return NULL;
+	}
+}
+
+int
+archive_entry_set_digest(struct archive_entry *entry, int type,
+    const unsigned char *digest)
+{
+#define copy_digest(_e, _t, _d)\
+	memcpy(_e->digest._t, _d, sizeof(_e->digest._t))
+
+	switch (type) {
+	case ARCHIVE_ENTRY_DIGEST_MD5:
+		copy_digest(entry, md5, digest);
+		break;
+	case ARCHIVE_ENTRY_DIGEST_RMD160:
+		copy_digest(entry, rmd160, digest);
+		break;
+	case ARCHIVE_ENTRY_DIGEST_SHA1:
+		copy_digest(entry, sha1, digest);
+		break;
+	case ARCHIVE_ENTRY_DIGEST_SHA256:
+		copy_digest(entry, sha256, digest);
+		break;
+	case ARCHIVE_ENTRY_DIGEST_SHA384:
+		copy_digest(entry, sha384, digest);
+		break;
+	case ARCHIVE_ENTRY_DIGEST_SHA512:
+		copy_digest(entry, sha512, digest);
+		break;
+	default:
+		return ARCHIVE_WARN;
+	}
+
+	return ARCHIVE_OK;
+#undef copy_digest
 }
 
 /*

Modified: vendor/libarchive/dist/libarchive/archive_entry.h
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_entry.h	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_entry.h	Tue Dec  1 10:36:46 2020	(r368207)
@@ -30,7 +30,7 @@
 #define	ARCHIVE_ENTRY_H_INCLUDED
 
 /* Note: Compiler will complain if this does not match archive.h! */
-#define	ARCHIVE_VERSION_NUMBER 3004003
+#define	ARCHIVE_VERSION_NUMBER 3005000
 
 /*
  * Note: archive_entry.h is for use outside of libarchive; the
@@ -395,6 +395,19 @@ __LA_DECL void	archive_entry_copy_stat(struct archive_
 
 __LA_DECL const void * archive_entry_mac_metadata(struct archive_entry *, size_t *);
 __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const void *, size_t);
+
+/*
+ * Digest routine. This is used to query the raw hex digest for the
+ * given entry. The type of digest is provided as an argument.
+ */
+#define ARCHIVE_ENTRY_DIGEST_MD5              0x00000001
+#define ARCHIVE_ENTRY_DIGEST_RMD160           0x00000002
+#define ARCHIVE_ENTRY_DIGEST_SHA1             0x00000003
+#define ARCHIVE_ENTRY_DIGEST_SHA256           0x00000004
+#define ARCHIVE_ENTRY_DIGEST_SHA384           0x00000005
+#define ARCHIVE_ENTRY_DIGEST_SHA512           0x00000006
+
+__LA_DECL const unsigned char * archive_entry_digest(struct archive_entry *, int /* type */);
 
 /*
  * ACL routines.  This used to simply store and return text-format ACL

Modified: vendor/libarchive/dist/libarchive/archive_entry_private.h
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_entry_private.h	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_entry_private.h	Tue Dec  1 10:36:46 2020	(r368207)
@@ -50,6 +50,15 @@ struct ae_sparse {
 	int64_t	 length;
 };
 
+struct ae_digest {
+	unsigned char md5[16];
+	unsigned char rmd160[20];
+	unsigned char sha1[20];
+	unsigned char sha256[32];
+	unsigned char sha384[48];
+	unsigned char sha512[64];
+};
+
 /*
  * Description of an archive entry.
  *
@@ -162,6 +171,9 @@ struct archive_entry {
 	void *mac_metadata;
 	size_t mac_metadata_size;
 
+	/* Digest support. */
+	struct ae_digest digest;
+
 	/* ACL support. */
 	struct archive_acl    acl;
 
@@ -180,5 +192,9 @@ struct archive_entry {
 	/* Symlink type support */
 	int ae_symlink_type;
 };
+
+int
+archive_entry_set_digest(struct archive_entry *entry, int type,
+    const unsigned char *digest);
 
 #endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */

Modified: vendor/libarchive/dist/libarchive/archive_ppmd7.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_ppmd7.c	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_ppmd7.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -4,7 +4,7 @@ This code is based on PPMd var.H (2001): Dmitry Shkari
 
 #include "archive_platform.h"
 
-#include <memory.h>
+#include <stdlib.h>
 
 #include "archive_ppmd7_private.h"
 

Modified: vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -103,6 +103,10 @@ __FBSDID("$FreeBSD");
 
 static int setup_mac_metadata(struct archive_read_disk *,
     struct archive_entry *, int *fd);
+#ifdef ARCHIVE_XATTR_FREEBSD
+static int setup_xattrs_namespace(struct archive_read_disk *,
+    struct archive_entry *, int *, int);
+#endif
 static int setup_xattrs(struct archive_read_disk *,
     struct archive_entry *, int *fd);
 static int setup_sparse(struct archive_read_disk *,
@@ -701,14 +705,13 @@ setup_xattr(struct archive_read_disk *a, struct archiv
 }
 
 static int
-setup_xattrs(struct archive_read_disk *a,
-    struct archive_entry *entry, int *fd)
+setup_xattrs_namespace(struct archive_read_disk *a,
+    struct archive_entry *entry, int *fd, int namespace)
 {
 	char buff[512];
 	char *list, *p;
 	ssize_t list_size;
 	const char *path;
-	int namespace = EXTATTR_NAMESPACE_USER;
 
 	path = NULL;
 
@@ -727,6 +730,8 @@ setup_xattrs(struct archive_read_disk *a,
 
 	if (list_size == -1 && errno == EOPNOTSUPP)
 		return (ARCHIVE_OK);
+	if (list_size == -1 && errno == EPERM)
+		return (ARCHIVE_OK);
 	if (list_size == -1) {
 		archive_set_error(&a->archive, errno,
 			"Couldn't list extended attributes");
@@ -760,7 +765,17 @@ setup_xattrs(struct archive_read_disk *a,
 		size_t len = 255 & (int)*p;
 		char *name;
 
-		strcpy(buff, "user.");
+		if (namespace == EXTATTR_NAMESPACE_SYSTEM) {
+			if (!strcmp(p + 1, "nfs4.acl") ||
+			    !strcmp(p + 1, "posix1e.acl_access") ||
+			    !strcmp(p + 1, "posix1e.acl_default")) {
+				p += 1 + len;
+				continue;
+			}
+			strcpy(buff, "system.");
+		} else {
+			strcpy(buff, "user.");
+		}
 		name = buff + strlen(buff);
 		memcpy(name, p + 1, len);
 		name[len] = '\0';
@@ -769,6 +784,31 @@ setup_xattrs(struct archive_read_disk *a,
 	}
 
 	free(list);
+	return (ARCHIVE_OK);
+}
+
+static int
+setup_xattrs(struct archive_read_disk *a,
+    struct archive_entry *entry, int *fd)
+{
+	int namespaces[2];
+	int i, res;
+
+	namespaces[0] = EXTATTR_NAMESPACE_USER;
+	namespaces[1] = EXTATTR_NAMESPACE_SYSTEM;
+
+	for (i = 0; i < 2; i++) {
+		res = setup_xattrs_namespace(a, entry, fd,
+		    namespaces[i]);
+		switch (res) {
+			case (ARCHIVE_OK):
+			case (ARCHIVE_WARN):
+				break;
+			default:
+				return (res);
+		}
+	}
+
 	return (ARCHIVE_OK);
 }
 

Modified: vendor/libarchive/dist/libarchive/archive_read_filter.3
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_read_filter.3	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_read_filter.3	Tue Dec  1 10:36:46 2020	(r368207)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 14, 2014
+.Dd June 9, 2020
 .Dt ARCHIVE_READ_FILTER 3
 .Os
 .Sh NAME
@@ -50,6 +50,8 @@ Streaming Archive Library (libarchive, -larchive)
 .Ft int
 .Fn archive_read_support_filter_all "struct archive *"
 .Ft int
+.Fn archive_read_support_filter_by_code "struct archive *" "int"
+.Ft int
 .Fn archive_read_support_filter_bzip2 "struct archive *"
 .Ft int
 .Fn archive_read_support_filter_compress "struct archive *"
@@ -116,6 +118,14 @@ Note that
 is always enabled by default.
 .It Fn archive_read_support_filter_all
 Enables all available decompression filters.
+.It Fn archive_read_support_filter_by_code
+Enables a single filter specified by the filter code.
+This function does not work with
+.Cm ARCHIVE_FILTER_PROGRAM .
+Note: In statically-linked executables, this will cause
+your program to include support for every filter.
+If executable size is a concern, you may wish to avoid
+using this function.
 .It Fn archive_read_support_filter_program
 Data is fed through the specified external program before being dearchived.
 Note that this disables automatic detection of the compression format,

Modified: vendor/libarchive/dist/libarchive/archive_read_set_format.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_read_set_format.c	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_read_set_format.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -61,6 +61,9 @@ archive_read_set_format(struct archive *_a, int code)
     case ARCHIVE_FORMAT_CPIO:
       strcpy(str, "cpio");
       break;
+    case ARCHIVE_FORMAT_EMPTY:
+      strcpy(str, "empty");
+      break;
     case ARCHIVE_FORMAT_ISO9660:
       strcpy(str, "iso9660");
       break;
@@ -76,8 +79,14 @@ archive_read_set_format(struct archive *_a, int code)
     case ARCHIVE_FORMAT_RAR_V5:
       strcpy(str, "rar5");
       break;
+    case ARCHIVE_FORMAT_RAW:
+      strcpy(str, "raw");
+      break;
     case ARCHIVE_FORMAT_TAR:
       strcpy(str, "tar");
+      break;
+    case ARCHIVE_FORMAT_WARC:
+      strcpy(str, "warc");
       break;
     case ARCHIVE_FORMAT_XAR:
       strcpy(str, "xar");

Added: vendor/libarchive/dist/libarchive/archive_read_support_filter_by_code.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/libarchive/dist/libarchive/archive_read_support_filter_by_code.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -0,0 +1,83 @@
+/*-
+ * Copyright (c) 2020 Martin Matuska
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD$");
+
+#include "archive.h"
+#include "archive_private.h"
+
+int
+archive_read_support_filter_by_code(struct archive *a, int filter_code)
+{
+	archive_check_magic(a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_filter_by_code");
+
+	switch (filter_code) {
+	case ARCHIVE_FILTER_NONE:
+		return archive_read_support_filter_none(a);
+		break;
+	case ARCHIVE_FILTER_GZIP:
+		return archive_read_support_filter_gzip(a);
+		break;
+	case ARCHIVE_FILTER_BZIP2:
+		return archive_read_support_filter_bzip2(a);
+		break;
+	case ARCHIVE_FILTER_COMPRESS:
+		return archive_read_support_filter_compress(a);
+		break;
+	case ARCHIVE_FILTER_LZMA:
+		return archive_read_support_filter_lzma(a);
+		break;
+	case ARCHIVE_FILTER_XZ:
+		return archive_read_support_filter_xz(a);
+		break;
+	case ARCHIVE_FILTER_UU:
+		return archive_read_support_filter_uu(a);
+		break;
+	case ARCHIVE_FILTER_RPM:
+		return archive_read_support_filter_rpm(a);
+		break;
+	case ARCHIVE_FILTER_LZIP:
+		return archive_read_support_filter_lzip(a);
+		break;
+	case ARCHIVE_FILTER_LRZIP:
+		return archive_read_support_filter_lrzip(a);
+		break;
+	case ARCHIVE_FILTER_LZOP:
+		return archive_read_support_filter_lzop(a);
+		break;
+	case ARCHIVE_FILTER_GRZIP:
+		return archive_read_support_filter_grzip(a);
+		break;
+	case ARCHIVE_FILTER_LZ4:
+		return archive_read_support_filter_lz4(a);
+		break;
+	case ARCHIVE_FILTER_ZSTD:
+		return archive_read_support_filter_zstd(a);
+		break;
+	}
+	return (ARCHIVE_FATAL);
+}

Modified: vendor/libarchive/dist/libarchive/archive_read_support_format_by_code.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_read_support_format_by_code.c	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_read_support_format_by_code.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -26,6 +26,10 @@
 #include "archive_platform.h"
 __FBSDID("$FreeBSD$");
 
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
 #include "archive.h"
 #include "archive_private.h"
 
@@ -48,6 +52,9 @@ archive_read_support_format_by_code(struct archive *a,
 	case ARCHIVE_FORMAT_CPIO:
 		return archive_read_support_format_cpio(a);
 		break;
+	case ARCHIVE_FORMAT_EMPTY:
+		return archive_read_support_format_empty(a);
+		break;
 	case ARCHIVE_FORMAT_ISO9660:
 		return archive_read_support_format_iso9660(a);
 		break;
@@ -63,9 +70,15 @@ archive_read_support_format_by_code(struct archive *a,
 	case ARCHIVE_FORMAT_RAR_V5:
 		return archive_read_support_format_rar5(a);
 		break;
+	case ARCHIVE_FORMAT_RAW:
+		return archive_read_support_format_raw(a);
+		break;
 	case ARCHIVE_FORMAT_TAR:
 		return archive_read_support_format_tar(a);
 		break;
+	case ARCHIVE_FORMAT_WARC:
+		return archive_read_support_format_warc(a);
+		break;
 	case ARCHIVE_FORMAT_XAR:
 		return archive_read_support_format_xar(a);
 		break;
@@ -73,5 +86,7 @@ archive_read_support_format_by_code(struct archive *a,
 		return archive_read_support_format_zip(a);
 		break;
 	}
+	archive_set_error(a, ARCHIVE_ERRNO_PROGRAMMER,
+	    "Invalid format code specified");
 	return (ARCHIVE_FATAL);
 }

Modified: vendor/libarchive/dist/libarchive/archive_read_support_format_cab.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_read_support_format_cab.c	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_read_support_format_cab.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -1172,7 +1172,7 @@ cab_checksum_finish(struct archive_read *a)
 	    cfdata->memimage + CFDATA_cbData, l, cfdata->sum_calculated);
 	if (cfdata->sum_calculated != cfdata->sum) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Checksum error CFDATA[%d] %x:%x in %d bytes",
+		    "Checksum error CFDATA[%d] %" PRIx32 ":%" PRIx32 " in %d bytes",
 		    cab->entry_cffolder->cfdata_index -1,
 		    cfdata->sum, cfdata->sum_calculated,
 		    cfdata->compressed_size);

Modified: vendor/libarchive/dist/libarchive/archive_read_support_format_empty.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_read_support_format_empty.c	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_read_support_format_empty.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -47,7 +47,7 @@ archive_read_support_format_empty(struct archive *_a)
 
 	r = __archive_read_register_format(a,
 	    NULL,
-	    NULL,
+	    "empty",
 	    archive_read_format_empty_bid,
 	    NULL,
 	    archive_read_format_empty_read_header,

Modified: vendor/libarchive/dist/libarchive/archive_read_support_format_mtree.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_read_support_format_mtree.c	Tue Dec  1 09:55:28 2020	(r368206)
+++ vendor/libarchive/dist/libarchive/archive_read_support_format_mtree.c	Tue Dec  1 10:36:46 2020	(r368207)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_s
 
 #include "archive.h"
 #include "archive_entry.h"
+#include "archive_entry_private.h"
 #include "archive_private.h"
 #include "archive_rb.h"
 #include "archive_read_private.h"
@@ -1482,6 +1483,84 @@ parse_device(dev_t *pdev, struct archive *a, char *val
 #undef MAX_PACK_ARGS
 }
 
+static int
+parse_hex_nibble(char c)
+{
+	if (c >= '0' && c <= '9')
+		return c - '0';
+	if (c >= 'a' && c <= 'f')
+		return 10 + c - 'a';
+#if 0
+	/* XXX: Is uppercase something we should support? */
+	if (c >= 'A' && c <= 'F')
+		return 10 + c - 'A';
+#endif
+
+	return -1;
+}
+
+static int
+parse_digest(struct archive_read *a, struct archive_entry *entry,
+    const char *digest, int type)
+{
+	unsigned char digest_buf[64];
+	int high, low;
+	size_t i, j, len;
+
+	switch (type) {
+	case ARCHIVE_ENTRY_DIGEST_MD5:
+		len = sizeof(entry->digest.md5);
+		break;
+	case ARCHIVE_ENTRY_DIGEST_RMD160:
+		len = sizeof(entry->digest.rmd160);
+		break;
+	case ARCHIVE_ENTRY_DIGEST_SHA1:
+		len = sizeof(entry->digest.sha1);
+		break;
+	case ARCHIVE_ENTRY_DIGEST_SHA256:
+		len = sizeof(entry->digest.sha256);
+		break;
+	case ARCHIVE_ENTRY_DIGEST_SHA384:
+		len = sizeof(entry->digest.sha384);
+		break;
+	case ARCHIVE_ENTRY_DIGEST_SHA512:
+		len = sizeof(entry->digest.sha512);
+		break;
+	default:
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
+			"Internal error: Unknown digest type");
+		return ARCHIVE_FATAL;
+	}
+
+	if (len > sizeof(digest_buf)) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
+			"Internal error: Digest storage too large");
+		return ARCHIVE_FATAL;
+	}
+
+	len *= 2;
+
+	if (strnlen(digest, len+1) != len) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+				  "incorrect digest length, ignoring");
+		return ARCHIVE_WARN;
+	}
+
+	for (i = 0, j = 0; i < len; i += 2, j++) {
+		high = parse_hex_nibble(digest[i]);
+		low = parse_hex_nibble(digest[i+1]);
+		if (high == -1 || low == -1) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+					  "invalid digest data, ignoring");
+			return ARCHIVE_WARN;
+		}
+
+		digest_buf[j] = high << 4 | low;
+	}
+
+	return archive_entry_set_digest(entry, type, digest_buf);
+}
+
 /*
  * Parse a single keyword and its value.
  */
@@ -1580,8 +1659,10 @@ parse_keyword(struct archive_read *a, struct mtree *mt
 		}
 		__LA_FALLTHROUGH;
 	case 'm':
-		if (strcmp(key, "md5") == 0 || strcmp(key, "md5digest") == 0)
-			break;
+		if (strcmp(key, "md5") == 0 || strcmp(key, "md5digest") == 0) {
+			return parse_digest(a, entry, val,
+			    ARCHIVE_ENTRY_DIGEST_MD5);
+		}
 		if (strcmp(key, "mode") == 0) {
 			if (val[0] >= '0' && val[0] <= '7') {
 				*parsed_kws |= MTREE_HAS_PERM;
@@ -1617,21 +1698,32 @@ parse_keyword(struct archive_read *a, struct mtree *mt
 			return r;
 		}
 		if (strcmp(key, "rmd160") == 0 ||
-		    strcmp(key, "rmd160digest") == 0)
-			break;
+		    strcmp(key, "rmd160digest") == 0) {
+			return parse_digest(a, entry, val,
+			    ARCHIVE_ENTRY_DIGEST_RMD160);
+		}
 		__LA_FALLTHROUGH;
 	case 's':
-		if (strcmp(key, "sha1") == 0 || strcmp(key, "sha1digest") == 0)
-			break;
+		if (strcmp(key, "sha1") == 0 ||
+		    strcmp(key, "sha1digest") == 0) {
+			return parse_digest(a, entry, val,
+			    ARCHIVE_ENTRY_DIGEST_SHA1);
+		}
 		if (strcmp(key, "sha256") == 0 ||
-		    strcmp(key, "sha256digest") == 0)
-			break;
+		    strcmp(key, "sha256digest") == 0) {
+			return parse_digest(a, entry, val,
+			    ARCHIVE_ENTRY_DIGEST_SHA256);
+		}
 		if (strcmp(key, "sha384") == 0 ||

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


More information about the svn-src-all mailing list