Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Jan 2017 01:43:11 +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-10@freebsd.org
Subject:   svn commit: r311042 - in stable/10: contrib/libarchive contrib/libarchive/cat contrib/libarchive/cat/test contrib/libarchive/cpio contrib/libarchive/cpio/test contrib/libarchive/libarchive contrib/...
Message-ID:  <201701020143.v021hBnh013629@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mm
Date: Mon Jan  2 01:43:11 2017
New Revision: 311042
URL: https://svnweb.freebsd.org/changeset/base/311042

Log:
  MFC r309300,r309363,r309405,r309523,r309590,r310185,r310623:
  
  Sync libarchive with vendor.
  
  Fixed vendor issues (relevant to FreeBSD)
  #825, #832: Add sanity check of tar "uid, "gid" and "mtime" fields
  #830, #831, #833, #846: Spelling fixes
  #850: Fix issues with reading certain jar files
  
  Fixed issues found by Google OSS-Fuzz:
  OSS-Fuzz #15: Fix heap-buffer-overflow in archive_le16dec()
  OSS-Fuzz #16: Fix possible hang in uudecode_filter_read()
  OSS-Fuzz #139, #145, #152: Fix heap-buffer-overflow in uudecode_bidder_bid()
  OSS-Fuzz #220: Reject an 'ar' filename table larger than 1GB or a filename
                 larger than 1MB
  OSS-Fuzz #227, #230, #239: Fix possible memory leak in archive_read_free()
  OSS-Fuzz #237: Fix heap buffer overflow when reading invalid ar archives
  OSS-Fuzz #286: Bugfix in archive_strncat_l()
  
  More information:
  https://github.com/libarchive/libarchive/issues/[libarchive_issue_number]
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=[oss_fuzz_issue_number]

Added:
  stable/10/contrib/libarchive/libarchive/archive_openssl_evp_private.h
     - copied unchanged from r310185, head/contrib/libarchive/libarchive/archive_openssl_evp_private.h
  stable/10/contrib/libarchive/libarchive/archive_openssl_hmac_private.h
     - copied unchanged from r310185, head/contrib/libarchive/libarchive/archive_openssl_hmac_private.h
  stable/10/contrib/libarchive/libarchive/test/test_compat_gtar_2.tar.uu
     - copied unchanged from r309300, head/contrib/libarchive/libarchive/test/test_compat_gtar_2.tar.uu
  stable/10/contrib/libarchive/libarchive/test/test_compat_perl_archive_tar.c
     - copied unchanged from r309363, head/contrib/libarchive/libarchive/test/test_compat_perl_archive_tar.c
  stable/10/contrib/libarchive/libarchive/test/test_compat_perl_archive_tar.tar.uu
     - copied unchanged from r309363, head/contrib/libarchive/libarchive/test/test_compat_perl_archive_tar.tar.uu
  stable/10/contrib/libarchive/libarchive/test/test_compat_plexus_archiver_tar.c
     - copied unchanged from r309590, head/contrib/libarchive/libarchive/test/test_compat_plexus_archiver_tar.c
  stable/10/contrib/libarchive/libarchive/test/test_compat_plexus_archiver_tar.tar.uu
     - copied unchanged from r309590, head/contrib/libarchive/libarchive/test/test_compat_plexus_archiver_tar.tar.uu
  stable/10/contrib/libarchive/libarchive/test/test_compat_star_acl_posix1e.c
     - copied unchanged from r309300, head/contrib/libarchive/libarchive/test/test_compat_star_acl_posix1e.c
  stable/10/contrib/libarchive/libarchive/test/test_compat_star_acl_posix1e.tar.uu
     - copied unchanged from r309300, head/contrib/libarchive/libarchive/test/test_compat_star_acl_posix1e.tar.uu
  stable/10/contrib/libarchive/libarchive/test/test_read_format_raw.bufr.uu
     - copied unchanged from r309300, head/contrib/libarchive/libarchive/test/test_read_format_raw.bufr.uu
  stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_jar.c
     - copied unchanged from r310623, head/contrib/libarchive/libarchive/test/test_read_format_zip_jar.c
  stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_jar.jar.uu
     - copied unchanged from r310623, head/contrib/libarchive/libarchive/test/test_read_format_zip_jar.jar.uu
Modified:
  stable/10/contrib/libarchive/NEWS
  stable/10/contrib/libarchive/cat/bsdcat.c
  stable/10/contrib/libarchive/cat/test/main.c
  stable/10/contrib/libarchive/cpio/cpio.c
  stable/10/contrib/libarchive/cpio/test/main.c
  stable/10/contrib/libarchive/cpio/test/test_option_lz4.c
  stable/10/contrib/libarchive/cpio/test/test_owner_parse.c
  stable/10/contrib/libarchive/libarchive/archive.h
  stable/10/contrib/libarchive/libarchive/archive_acl.c
  stable/10/contrib/libarchive/libarchive/archive_cryptor.c
  stable/10/contrib/libarchive/libarchive/archive_cryptor_private.h
  stable/10/contrib/libarchive/libarchive/archive_digest.c
  stable/10/contrib/libarchive/libarchive/archive_digest_private.h
  stable/10/contrib/libarchive/libarchive/archive_entry.c
  stable/10/contrib/libarchive/libarchive/archive_entry.h
  stable/10/contrib/libarchive/libarchive/archive_entry_acl.3
  stable/10/contrib/libarchive/libarchive/archive_hmac.c
  stable/10/contrib/libarchive/libarchive/archive_hmac_private.h
  stable/10/contrib/libarchive/libarchive/archive_options.c
  stable/10/contrib/libarchive/libarchive/archive_read.c
  stable/10/contrib/libarchive/libarchive/archive_read_append_filter.c
  stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
  stable/10/contrib/libarchive/libarchive/archive_read_disk_posix.c
  stable/10/contrib/libarchive/libarchive/archive_read_extract2.c
  stable/10/contrib/libarchive/libarchive/archive_read_open_memory.c
  stable/10/contrib/libarchive/libarchive/archive_read_private.h
  stable/10/contrib/libarchive/libarchive/archive_read_support_filter_uu.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_filter_xz.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_7zip.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_ar.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_cab.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_cpio.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_rar.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_tar.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_warc.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_xar.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_zip.c
  stable/10/contrib/libarchive/libarchive/archive_string.c
  stable/10/contrib/libarchive/libarchive/archive_string.h
  stable/10/contrib/libarchive/libarchive/archive_write.c
  stable/10/contrib/libarchive/libarchive/archive_write_add_filter_lz4.c
  stable/10/contrib/libarchive/libarchive/archive_write_disk_posix.c
  stable/10/contrib/libarchive/libarchive/archive_write_disk_set_standard_lookup.c
  stable/10/contrib/libarchive/libarchive/archive_write_open_memory.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_7zip.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_ar.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_cpio.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_cpio_newc.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_mtree.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_pax.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_shar.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_ustar.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_v7tar.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_xar.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_zip.c
  stable/10/contrib/libarchive/libarchive/test/main.c
  stable/10/contrib/libarchive/libarchive/test/test_archive_cmdline.c
  stable/10/contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c
  stable/10/contrib/libarchive/libarchive/test/test_compat_gtar.c
  stable/10/contrib/libarchive/libarchive/test/test_pax_filename_encoding.c
  stable/10/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c
  stable/10/contrib/libarchive/libarchive/test/test_read_format_raw.c
  stable/10/contrib/libarchive/libarchive/test/test_sparse_basic.c
  stable/10/contrib/libarchive/libarchive/test/test_write_disk_appledouble.c
  stable/10/contrib/libarchive/libarchive/test/test_write_format_xar_empty.c
  stable/10/contrib/libarchive/libarchive/test/test_write_format_zip_empty.c
  stable/10/contrib/libarchive/libarchive/test/test_write_format_zip_empty_zip64.c
  stable/10/contrib/libarchive/tar/creation_set.c
  stable/10/contrib/libarchive/tar/read.c
  stable/10/contrib/libarchive/tar/test/main.c
  stable/10/contrib/libarchive/tar/test/test_copy.c
  stable/10/contrib/libarchive/tar/test/test_option_lz4.c
  stable/10/contrib/libarchive/tar/write.c
  stable/10/lib/libarchive/tests/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/libarchive/NEWS
==============================================================================
--- stable/10/contrib/libarchive/NEWS	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/NEWS	Mon Jan  2 01:43:11 2017	(r311042)
@@ -1,3 +1,5 @@
+Oct 26, 2016: Remove liblzmadec support
+
 Oct 23, 2016: libarchive 3.2.2 released
     Security release
 

Modified: stable/10/contrib/libarchive/cat/bsdcat.c
==============================================================================
--- stable/10/contrib/libarchive/cat/bsdcat.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/cat/bsdcat.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -142,5 +142,8 @@ main(int argc, char **argv)
 			bsdcat_next();
 		}
 
+	if (a != NULL)
+		archive_read_free(a);
+
 	exit(exit_status);
 }

Modified: stable/10/contrib/libarchive/cat/test/main.c
==============================================================================
--- stable/10/contrib/libarchive/cat/test/main.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/cat/test/main.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -520,7 +520,7 @@ _utf8_to_unicode(uint32_t *pwc, const ch
 		return (0); /* Standard:  return 0 for end-of-string. */
 	cnt = utf8_count[ch];
 
-	/* Invalide sequence or there are not plenty bytes. */
+	/* Invalid sequence or there are not plenty bytes. */
 	if (n < (size_t)cnt)
 		return (-1);
 
@@ -559,7 +559,7 @@ _utf8_to_unicode(uint32_t *pwc, const ch
 		return (-1);
 	}
 
-	/* The code point larger than 0x10FFFF is not leagal
+	/* The code point larger than 0x10FFFF is not legal
 	 * Unicode values. */
 	if (wc > 0x10FFFF)
 		return (-1);

Modified: stable/10/contrib/libarchive/cpio/cpio.c
==============================================================================
--- stable/10/contrib/libarchive/cpio/cpio.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/cpio/cpio.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -1324,10 +1324,9 @@ lookup_name(struct cpio *cpio, struct na
 
 
 	if (*name_cache_variable == NULL) {
-		*name_cache_variable = malloc(sizeof(struct name_cache));
+		*name_cache_variable = calloc(1, sizeof(struct name_cache));
 		if (*name_cache_variable == NULL)
 			lafe_errc(1, ENOMEM, "No more memory");
-		memset(*name_cache_variable, 0, sizeof(struct name_cache));
 		(*name_cache_variable)->size = name_cache_size;
 	}
 

Modified: stable/10/contrib/libarchive/cpio/test/main.c
==============================================================================
--- stable/10/contrib/libarchive/cpio/test/main.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/cpio/test/main.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -521,7 +521,7 @@ _utf8_to_unicode(uint32_t *pwc, const ch
 		return (0); /* Standard:  return 0 for end-of-string. */
 	cnt = utf8_count[ch];
 
-	/* Invalide sequence or there are not plenty bytes. */
+	/* Invalid sequence or there are not plenty bytes. */
 	if (n < (size_t)cnt)
 		return (-1);
 
@@ -560,7 +560,7 @@ _utf8_to_unicode(uint32_t *pwc, const ch
 		return (-1);
 	}
 
-	/* The code point larger than 0x10FFFF is not leagal
+	/* The code point larger than 0x10FFFF is not legal
 	 * Unicode values. */
 	if (wc > 0x10FFFF)
 		return (-1);

Modified: stable/10/contrib/libarchive/cpio/test/test_option_lz4.c
==============================================================================
--- stable/10/contrib/libarchive/cpio/test/test_option_lz4.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/cpio/test/test_option_lz4.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -63,6 +63,13 @@ DEFINE_TEST(test_option_lz4)
 			    "but no such program is available on this system.");
 			return;
 		}
+		/* On some systems the error won't be detected until closing
+		   time, by a 127 exit error returned by waitpid. */
+		if (strstr(p, "Error closing") != NULL && !canLz4()) {
+			skipping("This version of bsdcpio uses an external lz4 program "
+			    "but no such program is available on this system.");
+			return;
+		}
 		failure("--lz4 option is broken: %s", p);
 		assertEqualInt(r, 0);
 		return;

Modified: stable/10/contrib/libarchive/cpio/test/test_owner_parse.c
==============================================================================
--- stable/10/contrib/libarchive/cpio/test/test_owner_parse.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/cpio/test/test_owner_parse.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -38,7 +38,7 @@ static const int root_gids[] = { 0, 1 };
  * its primary group membership depends on how the user set up
  * their /etc/passwd. Likely values are 513 (None), 545 (Users),
  * or 544 (Administrators). Just check for one of those...
- * TODO: Handle non-English localizations...e.g. French 'Administrateur'
+ * TODO: Handle non-English localizations... e.g. French 'Administrateur'
  *       Use CreateWellKnownSID() and LookupAccountName()?
  */
 #define ROOT "Administrator"

Modified: stable/10/contrib/libarchive/libarchive/archive.h
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive.h	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive.h	Mon Jan  2 01:43:11 2017	(r311042)
@@ -373,7 +373,7 @@ typedef const char *archive_passphrase_c
  *   4) Repeatedly call archive_read_next_header to get information about
  *      successive archive entries.  Call archive_read_data to extract
  *      data for entries of interest.
- *   5) Call archive_read_finish to end processing.
+ *   5) Call archive_read_free to end processing.
  */
 __LA_DECL struct archive	*archive_read_new(void);
 
@@ -562,7 +562,7 @@ __LA_DECL la_int64_t		 archive_read_head
  * we cannot say whether there are encrypted entries, then
  * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
  * In general, this function will return values below zero when the
- * reader is uncertain or totally uncapable of encryption support.
+ * reader is uncertain or totally incapable of encryption support.
  * When this function returns 0 you can be sure that the reader
  * supports encryption detection but no encrypted entries have
  * been found yet.
@@ -984,12 +984,12 @@ __LA_DECL int	archive_read_disk_can_desc
 __LA_DECL int	archive_read_disk_current_filesystem(struct archive *);
 __LA_DECL int	archive_read_disk_current_filesystem_is_synthetic(struct archive *);
 __LA_DECL int	archive_read_disk_current_filesystem_is_remote(struct archive *);
-/* Request that the access time of the entry visited by travesal be restored. */
+/* Request that the access time of the entry visited by traversal be restored. */
 __LA_DECL int  archive_read_disk_set_atime_restored(struct archive *);
 /*
  * Set behavior. The "flags" argument selects optional behavior.
  */
-/* Request that the access time of the entry visited by travesal be restored.
+/* Request that the access time of the entry visited by traversal be restored.
  * This is the same as archive_read_disk_set_atime_restored. */
 #define	ARCHIVE_READDISK_RESTORE_ATIME		(0x0001)
 /* Default: Do not skip an entry which has nodump flags. */
@@ -1124,7 +1124,7 @@ __LA_DECL int	archive_match_time_exclude
 
 /*
  * Flags to tell a matching type of time stamps. These are used for
- * following functinos.
+ * following functions.
  */
 /* Time flag: mtime to be tested. */
 #define ARCHIVE_MATCH_MTIME	(0x0100)
@@ -1144,7 +1144,7 @@ __LA_DECL int	archive_match_include_date
 		    const char *_datestr);
 __LA_DECL int	archive_match_include_date_w(struct archive *, int _flag,
 		    const wchar_t *_datestr);
-/* Set inclusion time by a particluar file. */
+/* Set inclusion time by a particular file. */
 __LA_DECL int	archive_match_include_file_time(struct archive *,
 		    int _flag, const char *_pathname);
 __LA_DECL int	archive_match_include_file_time_w(struct archive *,

Modified: stable/10/contrib/libarchive/libarchive/archive_acl.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_acl.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_acl.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -94,6 +94,7 @@ archive_acl_clear(struct archive_acl *ac
 		acl->acl_text = NULL;
 	}
 	acl->acl_p = NULL;
+	acl->acl_types = 0;
 	acl->acl_state = 0; /* Not counting. */
 }
 
@@ -279,23 +280,31 @@ acl_new_entry(struct archive_acl *acl,
 		acl->acl_text = NULL;
 	}
 
-	/* If there's a matching entry already in the list, overwrite it. */
+	/*
+	 * If there's a matching entry already in the list, overwrite it.
+	 * NFSv4 entries may be repeated and are not overwritten.
+	 *
+	 * TODO: compare names of no id is provided (needs more rework)
+	 */
 	ap = acl->acl_head;
 	aq = NULL;
 	while (ap != NULL) {
-		if (ap->type == type && ap->tag == tag && ap->id == id) {
-			ap->permset = permset;
-			return (ap);
+		if (((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) == 0) &&
+		    ap->type == type && ap->tag == tag && ap->id == id) {
+			if (id != -1 || (tag != ARCHIVE_ENTRY_ACL_USER &&
+			    tag != ARCHIVE_ENTRY_ACL_GROUP)) {
+				ap->permset = permset;
+				return (ap);
+			}
 		}
 		aq = ap;
 		ap = ap->next;
 	}
 
 	/* Add a new entry to the end of the list. */
-	ap = (struct archive_acl_entry *)malloc(sizeof(*ap));
+	ap = (struct archive_acl_entry *)calloc(1, sizeof(*ap));
 	if (ap == NULL)
 		return (NULL);
-	memset(ap, 0, sizeof(*ap));
 	if (aq == NULL)
 		acl->acl_head = ap;
 	else

Modified: stable/10/contrib/libarchive/libarchive/archive_cryptor.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_cryptor.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_cryptor.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -302,6 +302,8 @@ aes_ctr_release(archive_crypto_ctx *ctx)
 static int
 aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
 {
+	if ((ctx->ctx = EVP_CIPHER_CTX_new()) == NULL)
+		return -1;
 
 	switch (key_len) {
 	case 16: ctx->type = EVP_aes_128_ecb(); break;
@@ -314,7 +316,7 @@ aes_ctr_init(archive_crypto_ctx *ctx, co
 	memcpy(ctx->key, key, key_len);
 	memset(ctx->nonce, 0, sizeof(ctx->nonce));
 	ctx->encr_pos = AES_BLOCK_SIZE;
-	EVP_CIPHER_CTX_init(&ctx->ctx);
+	EVP_CIPHER_CTX_init(ctx->ctx);
 	return 0;
 }
 
@@ -324,10 +326,10 @@ aes_ctr_encrypt_counter(archive_crypto_c
 	int outl = 0;
 	int r;
 
-	r = EVP_EncryptInit_ex(&ctx->ctx, ctx->type, NULL, ctx->key, NULL);
+	r = EVP_EncryptInit_ex(ctx->ctx, ctx->type, NULL, ctx->key, NULL);
 	if (r == 0)
 		return -1;
-	r = EVP_EncryptUpdate(&ctx->ctx, ctx->encr_buf, &outl, ctx->nonce,
+	r = EVP_EncryptUpdate(ctx->ctx, ctx->encr_buf, &outl, ctx->nonce,
 	    AES_BLOCK_SIZE);
 	if (r == 0 || outl != AES_BLOCK_SIZE)
 		return -1;
@@ -337,7 +339,7 @@ aes_ctr_encrypt_counter(archive_crypto_c
 static int
 aes_ctr_release(archive_crypto_ctx *ctx)
 {
-	EVP_CIPHER_CTX_cleanup(&ctx->ctx);
+	EVP_CIPHER_CTX_free(ctx->ctx);
 	memset(ctx->key, 0, ctx->key_len);
 	memset(ctx->nonce, 0, sizeof(ctx->nonce));
 	return 0;

Modified: stable/10/contrib/libarchive/libarchive/archive_cryptor_private.h
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_cryptor_private.h	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_cryptor_private.h	Mon Jan  2 01:43:11 2017	(r311042)
@@ -99,12 +99,12 @@ typedef struct {
 } archive_crypto_ctx;
 
 #elif defined(HAVE_LIBCRYPTO)
-#include <openssl/evp.h>
+#include "archive_openssl_evp_private.h"
 #define AES_BLOCK_SIZE	16
 #define AES_MAX_KEY_SIZE 32
 
 typedef struct {
-	EVP_CIPHER_CTX	ctx;
+	EVP_CIPHER_CTX	*ctx;
 	const EVP_CIPHER *type;
 	uint8_t		key[AES_MAX_KEY_SIZE];
 	unsigned	key_len;

Modified: stable/10/contrib/libarchive/libarchive/archive_digest.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_digest.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_digest.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -207,7 +207,9 @@ __archive_nettle_md5final(archive_md5_ct
 static int
 __archive_openssl_md5init(archive_md5_ctx *ctx)
 {
-  EVP_DigestInit(ctx, EVP_md5());
+  if ((*ctx = EVP_MD_CTX_new()) == NULL)
+	return (ARCHIVE_FAILED);
+  EVP_DigestInit(*ctx, EVP_md5());
   return (ARCHIVE_OK);
 }
 
@@ -215,7 +217,7 @@ static int
 __archive_openssl_md5update(archive_md5_ctx *ctx, const void *indata,
     size_t insize)
 {
-  EVP_DigestUpdate(ctx, indata, insize);
+  EVP_DigestUpdate(*ctx, indata, insize);
   return (ARCHIVE_OK);
 }
 
@@ -226,8 +228,11 @@ __archive_openssl_md5final(archive_md5_c
    * this is meant to cope with that. Real fix is probably to fix
    * archive_write_set_format_xar.c
    */
-  if (ctx->digest)
-    EVP_DigestFinal(ctx, md, NULL);
+  if (*ctx) {
+    EVP_DigestFinal(*ctx, md, NULL);
+    EVP_MD_CTX_free(*ctx);
+    *ctx = NULL;
+  }
   return (ARCHIVE_OK);
 }
 
@@ -359,7 +364,9 @@ __archive_nettle_ripemd160final(archive_
 static int
 __archive_openssl_ripemd160init(archive_rmd160_ctx *ctx)
 {
-  EVP_DigestInit(ctx, EVP_ripemd160());
+  if ((*ctx = EVP_MD_CTX_new()) == NULL)
+	return (ARCHIVE_FAILED);
+  EVP_DigestInit(*ctx, EVP_ripemd160());
   return (ARCHIVE_OK);
 }
 
@@ -367,14 +374,18 @@ static int
 __archive_openssl_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
     size_t insize)
 {
-  EVP_DigestUpdate(ctx, indata, insize);
+  EVP_DigestUpdate(*ctx, indata, insize);
   return (ARCHIVE_OK);
 }
 
 static int
 __archive_openssl_ripemd160final(archive_rmd160_ctx *ctx, void *md)
 {
-  EVP_DigestFinal(ctx, md, NULL);
+  if (*ctx) {
+    EVP_DigestFinal(*ctx, md, NULL);
+    EVP_MD_CTX_free(*ctx);
+    *ctx = NULL;
+  }
   return (ARCHIVE_OK);
 }
 
@@ -509,7 +520,9 @@ __archive_nettle_sha1final(archive_sha1_
 static int
 __archive_openssl_sha1init(archive_sha1_ctx *ctx)
 {
-  EVP_DigestInit(ctx, EVP_sha1());
+  if ((*ctx = EVP_MD_CTX_new()) == NULL)
+	return (ARCHIVE_FAILED);
+  EVP_DigestInit(*ctx, EVP_sha1());
   return (ARCHIVE_OK);
 }
 
@@ -517,7 +530,7 @@ static int
 __archive_openssl_sha1update(archive_sha1_ctx *ctx, const void *indata,
     size_t insize)
 {
-  EVP_DigestUpdate(ctx, indata, insize);
+  EVP_DigestUpdate(*ctx, indata, insize);
   return (ARCHIVE_OK);
 }
 
@@ -528,8 +541,11 @@ __archive_openssl_sha1final(archive_sha1
    * this is meant to cope with that. Real fix is probably to fix
    * archive_write_set_format_xar.c
    */
-  if (ctx->digest)
-    EVP_DigestFinal(ctx, md, NULL);
+  if (*ctx) {
+    EVP_DigestFinal(*ctx, md, NULL);
+    EVP_MD_CTX_free(*ctx);
+    *ctx = NULL;
+  }
   return (ARCHIVE_OK);
 }
 
@@ -733,7 +749,9 @@ __archive_nettle_sha256final(archive_sha
 static int
 __archive_openssl_sha256init(archive_sha256_ctx *ctx)
 {
-  EVP_DigestInit(ctx, EVP_sha256());
+  if ((*ctx = EVP_MD_CTX_new()) == NULL)
+	return (ARCHIVE_FAILED);
+  EVP_DigestInit(*ctx, EVP_sha256());
   return (ARCHIVE_OK);
 }
 
@@ -741,14 +759,18 @@ static int
 __archive_openssl_sha256update(archive_sha256_ctx *ctx, const void *indata,
     size_t insize)
 {
-  EVP_DigestUpdate(ctx, indata, insize);
+  EVP_DigestUpdate(*ctx, indata, insize);
   return (ARCHIVE_OK);
 }
 
 static int
 __archive_openssl_sha256final(archive_sha256_ctx *ctx, void *md)
 {
-  EVP_DigestFinal(ctx, md, NULL);
+  if (*ctx) {
+    EVP_DigestFinal(*ctx, md, NULL);
+    EVP_MD_CTX_free(*ctx);
+    *ctx = NULL;
+  }
   return (ARCHIVE_OK);
 }
 
@@ -928,7 +950,9 @@ __archive_nettle_sha384final(archive_sha
 static int
 __archive_openssl_sha384init(archive_sha384_ctx *ctx)
 {
-  EVP_DigestInit(ctx, EVP_sha384());
+  if ((*ctx = EVP_MD_CTX_new()) == NULL)
+	return (ARCHIVE_FAILED);
+  EVP_DigestInit(*ctx, EVP_sha384());
   return (ARCHIVE_OK);
 }
 
@@ -936,14 +960,18 @@ static int
 __archive_openssl_sha384update(archive_sha384_ctx *ctx, const void *indata,
     size_t insize)
 {
-  EVP_DigestUpdate(ctx, indata, insize);
+  EVP_DigestUpdate(*ctx, indata, insize);
   return (ARCHIVE_OK);
 }
 
 static int
 __archive_openssl_sha384final(archive_sha384_ctx *ctx, void *md)
 {
-  EVP_DigestFinal(ctx, md, NULL);
+  if (*ctx) {
+    EVP_DigestFinal(*ctx, md, NULL);
+    EVP_MD_CTX_free(*ctx);
+    *ctx = NULL;
+  }
   return (ARCHIVE_OK);
 }
 
@@ -1147,7 +1175,9 @@ __archive_nettle_sha512final(archive_sha
 static int
 __archive_openssl_sha512init(archive_sha512_ctx *ctx)
 {
-  EVP_DigestInit(ctx, EVP_sha512());
+  if ((*ctx = EVP_MD_CTX_new()) == NULL)
+	return (ARCHIVE_FAILED);
+  EVP_DigestInit(*ctx, EVP_sha512());
   return (ARCHIVE_OK);
 }
 
@@ -1155,14 +1185,18 @@ static int
 __archive_openssl_sha512update(archive_sha512_ctx *ctx, const void *indata,
     size_t insize)
 {
-  EVP_DigestUpdate(ctx, indata, insize);
+  EVP_DigestUpdate(*ctx, indata, insize);
   return (ARCHIVE_OK);
 }
 
 static int
 __archive_openssl_sha512final(archive_sha512_ctx *ctx, void *md)
 {
-  EVP_DigestFinal(ctx, md, NULL);
+  if (*ctx) {
+    EVP_DigestFinal(*ctx, md, NULL);
+    EVP_MD_CTX_free(*ctx);
+    *ctx = NULL;
+  }
   return (ARCHIVE_OK);
 }
 

Modified: stable/10/contrib/libarchive/libarchive/archive_digest_private.h
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_digest_private.h	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_digest_private.h	Mon Jan  2 01:43:11 2017	(r311042)
@@ -134,7 +134,7 @@
   defined(ARCHIVE_CRYPTO_SHA384_OPENSSL) ||\
   defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
 #define	ARCHIVE_CRYPTO_OPENSSL 1
-#include <openssl/evp.h>
+#include "archive_openssl_evp_private.h"
 #endif
 
 /* Windows crypto headers */
@@ -161,7 +161,7 @@ typedef CC_MD5_CTX archive_md5_ctx;
 #elif defined(ARCHIVE_CRYPTO_MD5_NETTLE)
 typedef struct md5_ctx archive_md5_ctx;
 #elif defined(ARCHIVE_CRYPTO_MD5_OPENSSL)
-typedef EVP_MD_CTX archive_md5_ctx;
+typedef EVP_MD_CTX *archive_md5_ctx;
 #elif defined(ARCHIVE_CRYPTO_MD5_WIN)
 typedef Digest_CTX archive_md5_ctx;
 #else
@@ -175,7 +175,7 @@ typedef RIPEMD160_CTX archive_rmd160_ctx
 #elif defined(ARCHIVE_CRYPTO_RMD160_NETTLE)
 typedef struct ripemd160_ctx archive_rmd160_ctx;
 #elif defined(ARCHIVE_CRYPTO_RMD160_OPENSSL)
-typedef EVP_MD_CTX archive_rmd160_ctx;
+typedef EVP_MD_CTX *archive_rmd160_ctx;
 #else
 typedef unsigned char archive_rmd160_ctx;
 #endif
@@ -189,7 +189,7 @@ typedef CC_SHA1_CTX archive_sha1_ctx;
 #elif defined(ARCHIVE_CRYPTO_SHA1_NETTLE)
 typedef struct sha1_ctx archive_sha1_ctx;
 #elif defined(ARCHIVE_CRYPTO_SHA1_OPENSSL)
-typedef EVP_MD_CTX archive_sha1_ctx;
+typedef EVP_MD_CTX *archive_sha1_ctx;
 #elif defined(ARCHIVE_CRYPTO_SHA1_WIN)
 typedef Digest_CTX archive_sha1_ctx;
 #else
@@ -209,7 +209,7 @@ typedef CC_SHA256_CTX archive_sha256_ctx
 #elif defined(ARCHIVE_CRYPTO_SHA256_NETTLE)
 typedef struct sha256_ctx archive_sha256_ctx;
 #elif defined(ARCHIVE_CRYPTO_SHA256_OPENSSL)
-typedef EVP_MD_CTX archive_sha256_ctx;
+typedef EVP_MD_CTX *archive_sha256_ctx;
 #elif defined(ARCHIVE_CRYPTO_SHA256_WIN)
 typedef Digest_CTX archive_sha256_ctx;
 #else
@@ -227,7 +227,7 @@ typedef CC_SHA512_CTX archive_sha384_ctx
 #elif defined(ARCHIVE_CRYPTO_SHA384_NETTLE)
 typedef struct sha384_ctx archive_sha384_ctx;
 #elif defined(ARCHIVE_CRYPTO_SHA384_OPENSSL)
-typedef EVP_MD_CTX archive_sha384_ctx;
+typedef EVP_MD_CTX *archive_sha384_ctx;
 #elif defined(ARCHIVE_CRYPTO_SHA384_WIN)
 typedef Digest_CTX archive_sha384_ctx;
 #else
@@ -247,7 +247,7 @@ typedef CC_SHA512_CTX archive_sha512_ctx
 #elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE)
 typedef struct sha512_ctx archive_sha512_ctx;
 #elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
-typedef EVP_MD_CTX archive_sha512_ctx;
+typedef EVP_MD_CTX *archive_sha512_ctx;
 #elif defined(ARCHIVE_CRYPTO_SHA512_WIN)
 typedef Digest_CTX archive_sha512_ctx;
 #else

Modified: stable/10/contrib/libarchive/libarchive/archive_entry.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_entry.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_entry.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -248,10 +248,9 @@ archive_entry_new2(struct archive *a)
 {
 	struct archive_entry *entry;
 
-	entry = (struct archive_entry *)malloc(sizeof(*entry));
+	entry = (struct archive_entry *)calloc(1, sizeof(*entry));
 	if (entry == NULL)
 		return (NULL);
-	memset(entry, 0, sizeof(*entry));
 	entry->archive = a;
 	return (entry);
 }
@@ -1442,6 +1441,15 @@ archive_entry_acl_add_entry_w(struct arc
 }
 
 /*
+ * Return a bitmask of ACL types in an archive entry ACL list
+ */
+int
+archive_entry_acl_types(struct archive_entry *entry)
+{
+	return ((&entry->acl)->acl_types);
+}
+
+/*
  * Return a count of entries matching "want_type".
  */
 int

Modified: stable/10/contrib/libarchive/libarchive/archive_entry.h
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_entry.h	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_entry.h	Mon Jan  2 01:43:11 2017	(r311042)
@@ -508,6 +508,9 @@ __LA_DECL const wchar_t	*archive_entry_a
 __LA_DECL const char *archive_entry_acl_text(struct archive_entry *,
 		    int /* flags */);
 
+/* Return bitmask of ACL types in an archive entry */
+__LA_DECL int	 archive_entry_acl_types(struct archive_entry *);
+
 /* Return a count of entries matching 'want_type' */
 __LA_DECL int	 archive_entry_acl_count(struct archive_entry *, int /* want_type */);
 

Modified: stable/10/contrib/libarchive/libarchive/archive_entry_acl.3
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_entry_acl.3	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_entry_acl.3	Mon Jan  2 01:43:11 2017	(r311042)
@@ -33,7 +33,8 @@
 .Nm archive_entry_acl_next ,
 .Nm archive_entry_acl_next_w ,
 .Nm archive_entry_acl_reset ,
-.Nm archive_entry_acl_text_w
+.Nm archive_entry_acl_text_w ,
+.Nm archive_entry_acl_types
 .Nd functions for manipulating Access Control Lists in archive entry descriptions
 .Sh LIBRARY
 Streaming Archive Library (libarchive, -larchive)
@@ -85,6 +86,8 @@ Streaming Archive Library (libarchive, -
 .Fn archive_entry_acl_reset "struct archive_entry *a" "int type"
 .Ft const wchar_t *
 .Fn archive_entry_acl_text_w "struct archive_entry *a" "int flags"
+.Ft int
+.Fn archive_entry_acl_types "struct archive_entry *a"
 .\" enum?
 .Sh DESCRIPTION
 An
@@ -192,6 +195,11 @@ The returned long string is valid until 
 .Fn archive_entry_acl_add_entry_w
 or
 .Fn archive_entry_acl_text_w .
+.Pp
+.Fn archive_entry_acl_types
+get ACL entry types contained in an archive entry's ACL. As POSIX.1e and NFSv4
+ACL entries cannot be mixed, this function is a very efficient way to detect if
+an ACL already contains POSIX.1e or NFSv4 ACL entries.
 .Sh RETURN VALUES
 .Fn archive_entry_acl_count
 and
@@ -225,6 +233,9 @@ The returned long string is valid until 
 .Fn archive_entry_acl_add_entry_w
 or
 .Fn archive_entry_acl_text_w .
+.Pp
+.Fn archive_entry_acl_types
+returns a bitmask of ACL entry types or 0 if archive entry has no ACL entries.
 .Sh SEE ALSO
 .Xr archive_entry 3
 .Xr libarchive 3 ,

Modified: stable/10/contrib/libarchive/libarchive/archive_hmac.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_hmac.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_hmac.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -176,8 +176,10 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ct
 static int
 __hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
 {
-	HMAC_CTX_init(ctx);
-	HMAC_Init(ctx, key, key_len, EVP_sha1());
+	*ctx = HMAC_CTX_new();
+	if (*ctx == NULL)
+		return -1;
+	HMAC_Init_ex(*ctx, key, key_len, EVP_sha1(), NULL);
 	return 0;
 }
 
@@ -185,22 +187,22 @@ static void
 __hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data,
     size_t data_len)
 {
-	HMAC_Update(ctx, data, data_len);
+	HMAC_Update(*ctx, data, data_len);
 }
 
 static void
 __hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len)
 {
 	unsigned int len = (unsigned int)*out_len;
-	HMAC_Final(ctx, out, &len);
+	HMAC_Final(*ctx, out, &len);
 	*out_len = len;
 }
 
 static void
 __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
 {
-	HMAC_CTX_cleanup(ctx);
-	memset(ctx, 0, sizeof(*ctx));
+	HMAC_CTX_free(*ctx);
+	*ctx = NULL;
 }
 
 #else

Modified: stable/10/contrib/libarchive/libarchive/archive_hmac_private.h
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_hmac_private.h	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_hmac_private.h	Mon Jan  2 01:43:11 2017	(r311042)
@@ -70,9 +70,9 @@ typedef struct {
 typedef	struct hmac_sha1_ctx archive_hmac_sha1_ctx;
 
 #elif defined(HAVE_LIBCRYPTO)
-#include <openssl/hmac.h>
+#include "archive_openssl_hmac_private.h"
 
-typedef	HMAC_CTX archive_hmac_sha1_ctx;
+typedef	HMAC_CTX* archive_hmac_sha1_ctx;
 
 #else
 

Copied: stable/10/contrib/libarchive/libarchive/archive_openssl_evp_private.h (from r310185, head/contrib/libarchive/libarchive/archive_openssl_evp_private.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/contrib/libarchive/libarchive/archive_openssl_evp_private.h	Mon Jan  2 01:43:11 2017	(r311042, copy of r310185, head/contrib/libarchive/libarchive/archive_openssl_evp_private.h)
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef ARCHIVE_OPENSSL_EVP_PRIVATE_H_INCLUDED
+#define ARCHIVE_OPENSSL_EVP_PRIVATE_H_INCLUDED
+
+#include <openssl/evp.h>
+#include <openssl/opensslv.h>
+
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#include <stdlib.h> /* malloc, free */
+#include <string.h> /* memset */
+static inline EVP_MD_CTX *EVP_MD_CTX_new(void)
+{
+	EVP_MD_CTX *ctx = (EVP_MD_CTX *)calloc(1, sizeof(EVP_MD_CTX));
+	return ctx;
+}
+
+static inline void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
+{
+	EVP_MD_CTX_cleanup(ctx);
+	memset(ctx, 0, sizeof(*ctx));
+	free(ctx);
+}
+#endif
+
+#endif

Copied: stable/10/contrib/libarchive/libarchive/archive_openssl_hmac_private.h (from r310185, head/contrib/libarchive/libarchive/archive_openssl_hmac_private.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/contrib/libarchive/libarchive/archive_openssl_hmac_private.h	Mon Jan  2 01:43:11 2017	(r311042, copy of r310185, head/contrib/libarchive/libarchive/archive_openssl_hmac_private.h)
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef ARCHIVE_OPENSSL_HMAC_PRIVATE_H_INCLUDED
+#define ARCHIVE_OPENSSL_HMAC_PRIVATE_H_INCLUDED
+
+#include <openssl/hmac.h>
+#include <openssl/opensslv.h>
+
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#include <stdlib.h> /* malloc, free */
+#include <string.h> /* memset */
+static inline HMAC_CTX *HMAC_CTX_new(void)
+{
+	HMAC_CTX *ctx = (HMAC_CTX *)calloc(1, sizeof(HMAC_CTX));
+	return ctx;
+}
+
+static inline void HMAC_CTX_free(HMAC_CTX *ctx)
+{
+	HMAC_CTX_cleanup(ctx);
+	memset(ctx, 0, sizeof(*ctx));
+	free(ctx);
+}
+#endif
+
+#endif

Modified: stable/10/contrib/libarchive/libarchive/archive_options.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_options.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_options.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -26,6 +26,10 @@
 #include "archive_platform.h"
 __FBSDID("$FreeBSD$");
 
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
 #include "archive_options_private.h"
 
 static const char *
@@ -105,8 +109,11 @@ _archive_set_options(struct archive *a, 
 	if (options == NULL || options[0] == '\0')
 		return ARCHIVE_OK;
 
-	data = (char *)malloc(strlen(options) + 1);
-	strcpy(data, options);
+	if ((data = strdup(options)) == NULL) {
+		archive_set_error(a,
+		    ENOMEM, "Out of memory adding file to list");
+		return (ARCHIVE_FATAL);
+	}
 	s = (const char *)data;
 
 	do {

Modified: stable/10/contrib/libarchive/libarchive/archive_read.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_read.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_read.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
 
 static int	choose_filters(struct archive_read *);
 static int	choose_format(struct archive_read *);
+static int	close_filters(struct archive_read *);
 static struct archive_vtable *archive_read_vtable(void);
 static int64_t	_archive_filter_bytes(struct archive *, int);
 static int	_archive_filter_code(struct archive *, int);
@@ -528,7 +529,7 @@ archive_read_open1(struct archive *_a)
 	{
 		slot = choose_format(a);
 		if (slot < 0) {
-			__archive_read_close_filters(a);
+			close_filters(a);
 			a->archive.state = ARCHIVE_STATE_FATAL;
 			return (ARCHIVE_FATAL);
 		}
@@ -582,7 +583,6 @@ choose_filters(struct archive_read *a)
 			/* Verify the filter by asking it for some data. */
 			__archive_read_filter_ahead(a->filter, 1, &avail);
 			if (avail < 0) {
-				__archive_read_close_filters(a);
 				__archive_read_free_filters(a);
 				return (ARCHIVE_FATAL);
 			}
@@ -601,7 +601,6 @@ choose_filters(struct archive_read *a)
 		a->filter = filter;
 		r = (best_bidder->init)(a->filter);
 		if (r != ARCHIVE_OK) {
-			__archive_read_close_filters(a);
 			__archive_read_free_filters(a);
 			return (ARCHIVE_FATAL);
 		}
@@ -765,7 +764,7 @@ archive_read_header_position(struct arch
  * we cannot say whether there are encrypted entries, then
  * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
  * In general, this function will return values below zero when the
- * reader is uncertain or totally uncapable of encryption support.
+ * reader is uncertain or totally incapable of encryption support.
  * When this function returns 0 you can be sure that the reader
  * supports encryption detection but no encrypted entries have
  * been found yet.
@@ -986,8 +985,8 @@ _archive_read_data_block(struct archive 
 	return (a->format->read_data)(a, buff, size, offset);
 }
 
-int
-__archive_read_close_filters(struct archive_read *a)
+static int
+close_filters(struct archive_read *a)
 {
 	struct archive_read_filter *f = a->filter;
 	int r = ARCHIVE_OK;
@@ -1010,6 +1009,9 @@ __archive_read_close_filters(struct arch
 void
 __archive_read_free_filters(struct archive_read *a)
 {
+	/* Make sure filters are closed and their buffers are freed */
+	close_filters(a);
+
 	while (a->filter != NULL) {
 		struct archive_read_filter *t = a->filter->upstream;
 		free(a->filter);
@@ -1052,7 +1054,7 @@ _archive_read_close(struct archive *_a)
 	/* TODO: Clean up the formatters. */
 
 	/* Release the filter objects. */
-	r1 = __archive_read_close_filters(a);
+	r1 = close_filters(a);
 	if (r1 < r)
 		r = r1;
 

Modified: stable/10/contrib/libarchive/libarchive/archive_read_append_filter.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_read_append_filter.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_read_append_filter.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -133,7 +133,6 @@ archive_read_append_filter(struct archiv
     a->filter = filter;
     r2 = (bidder->init)(a->filter);
     if (r2 != ARCHIVE_OK) {
-      __archive_read_close_filters(a);
       __archive_read_free_filters(a);
       return (ARCHIVE_FATAL);
     }
@@ -191,7 +190,6 @@ archive_read_append_filter_program_signa
   a->filter = filter;
   r = (bidder->init)(a->filter);
   if (r != ARCHIVE_OK) {
-    __archive_read_close_filters(a);
     __archive_read_free_filters(a);
     return (ARCHIVE_FATAL);
   }

Modified: stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c	Mon Jan  2 01:41:31 2017	(r311041)
+++ stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c	Mon Jan  2 01:43:11 2017	(r311042)
@@ -125,6 +125,10 @@ static int setup_xattrs(struct archive_r
     struct archive_entry *, int *fd);
 static int setup_sparse(struct archive_read_disk *,
     struct archive_entry *, int *fd);
+#if defined(HAVE_LINUX_FIEMAP_H)
+static int setup_sparse_fiemap(struct archive_read_disk *,
+    struct archive_entry *, int *fd);
+#endif
 
 int
 archive_read_disk_entry_from_file(struct archive *_a,
@@ -686,7 +690,7 @@ translate_acl(struct archive_read_disk *
 #ifdef ACL_TYPE_NFS4
 		if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
 			/*
-			 * acl_get_entry_type_np() falis with non-NFSv4 ACLs
+			 * acl_get_entry_type_np() fails with non-NFSv4 ACLs
 			 */
 			if (acl_get_entry_type_np(acl_entry, &acl_type) != 0) {
 				archive_set_error(&a->archive, errno, "Failed "
@@ -1124,7 +1128,7 @@ setup_xattrs(struct archive_read_disk *a
 #if defined(HAVE_LINUX_FIEMAP_H)
 
 /*
- * Linux sparse interface.
+ * Linux FIEMAP sparse interface.
  *
  * The FIEMAP ioctl returns an "extent" for each physical allocation
  * on disk.  We need to process those to generate a more compact list
@@ -1139,7 +1143,7 @@ setup_xattrs(struct archive_read_disk *a
  */
 
 static int
-setup_sparse(struct archive_read_disk *a,
+setup_sparse_fiemap(struct archive_read_disk *a,
     struct archive_entry *entry, int *fd)
 {
 	char buff[4096];
@@ -1190,8 +1194,8 @@ setup_sparse(struct archive_read_disk *a
 		if (r < 0) {
 			/* When something error happens, it is better we
 			 * should return ARCHIVE_OK because an earlier
-			 * version(<2.6.28) cannot perfom FS_IOC_FIEMAP. */
-			goto exit_setup_sparse;
+			 * version(<2.6.28) cannot perform FS_IOC_FIEMAP. */
+			goto exit_setup_sparse_fiemap;
 		}
 		if (fm->fm_mapped_extents == 0) {
 			if (iters == 0) {
@@ -1226,14 +1230,24 @@ setup_sparse(struct archive_read_disk *a
 		} else
 			break;
 	}
-exit_setup_sparse:
+exit_setup_sparse_fiemap:
 	return (exit_sts);
 }
 
-#elif defined(SEEK_HOLE) && defined(SEEK_DATA) && defined(_PC_MIN_HOLE_SIZE)
+#if !defined(SEEK_HOLE) || !defined(SEEK_DATA)
+static int
+setup_sparse(struct archive_read_disk *a,
+    struct archive_entry *entry, int *fd)
+{
+	return setup_sparse_fiemap(a, entry, fd);
+}
+#endif
+#endif	/* defined(HAVE_LINUX_FIEMAP_H) */
+
+#if defined(SEEK_HOLE) && defined(SEEK_DATA)
 
 /*
- * FreeBSD and Solaris sparse interface.
+ * SEEK_HOLE sparse interface (FreeBSD, Linux, Solaris)
  */
 
 static int
@@ -1241,8 +1255,8 @@ setup_sparse(struct archive_read_disk *a
     struct archive_entry *entry, int *fd)
 {
 	int64_t size;
-	off_t initial_off; /* FreeBSD/Solaris only, so off_t okay here */
-	off_t off_s, off_e; /* FreeBSD/Solaris only, so off_t okay here */
+	off_t initial_off;
+	off_t off_s, off_e;
 	int exit_sts = ARCHIVE_OK;
 	int check_fully_sparse = 0;
 
@@ -1268,8 +1282,10 @@ setup_sparse(struct archive_read_disk *a
 	}
 
 	if (*fd >= 0) {
+#ifdef _PC_MIN_HOLE_SIZE
 		if (fpathconf(*fd, _PC_MIN_HOLE_SIZE) <= 0)
 			return (ARCHIVE_OK);
+#endif
 		initial_off = lseek(*fd, 0, SEEK_CUR);
 		if (initial_off != 0)
 			lseek(*fd, 0, SEEK_SET);
@@ -1280,8 +1296,10 @@ setup_sparse(struct archive_read_disk *a
 		if (path == NULL)
 			path = archive_entry_pathname(entry);
 			
+#ifdef _PC_MIN_HOLE_SIZE
 		if (pathconf(path, _PC_MIN_HOLE_SIZE) <= 0)
 			return (ARCHIVE_OK);
+#endif
 		*fd = open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
 		if (*fd < 0) {
 			archive_set_error(&a->archive, errno,
@@ -1292,6 +1310,19 @@ setup_sparse(struct archive_read_disk *a
 		initial_off = 0;
 	}

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



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