svn commit: r356416 - head/contrib/libarchive/libarchive

Martin Matuska mm at FreeBSD.org
Mon Jan 6 13:21:12 UTC 2020


Author: mm
Date: Mon Jan  6 13:21:10 2020
New Revision: 356416
URL: https://svnweb.freebsd.org/changeset/base/356416

Log:
  MFV r356415
  Sync libarchive with vendor
  
  Relevant vendor changes:
    Issue #1302: Re-do fix for archive_write_client_open()
  
  X-MFC-With:	r356212,r356365
  MFC after:	1 week

Modified:
  head/contrib/libarchive/libarchive/archive_cryptor.c
  head/contrib/libarchive/libarchive/archive_hmac.c
  head/contrib/libarchive/libarchive/archive_write.c
Directory Properties:
  head/contrib/libarchive/   (props changed)

Modified: head/contrib/libarchive/libarchive/archive_cryptor.c
==============================================================================
--- head/contrib/libarchive/libarchive/archive_cryptor.c	Mon Jan  6 13:13:58 2020	(r356415)
+++ head/contrib/libarchive/libarchive/archive_cryptor.c	Mon Jan  6 13:21:10 2020	(r356416)
@@ -299,6 +299,7 @@ aes_ctr_release(archive_crypto_ctx *ctx)
 }
 
 #elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_AES_H)
+
 static int
 aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
 {

Modified: head/contrib/libarchive/libarchive/archive_hmac.c
==============================================================================
--- head/contrib/libarchive/libarchive/archive_hmac.c	Mon Jan  6 13:13:58 2020	(r356415)
+++ head/contrib/libarchive/libarchive/archive_hmac.c	Mon Jan  6 13:21:10 2020	(r356416)
@@ -151,6 +151,7 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
 }
 
 #elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_MD_H)
+
 static int
 __hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
 {

Modified: head/contrib/libarchive/libarchive/archive_write.c
==============================================================================
--- head/contrib/libarchive/libarchive/archive_write.c	Mon Jan  6 13:13:58 2020	(r356415)
+++ head/contrib/libarchive/libarchive/archive_write.c	Mon Jan  6 13:21:10 2020	(r356416)
@@ -339,6 +339,7 @@ archive_write_client_open(struct archive_write_filter 
 	struct archive_none *state;
 	void *buffer;
 	size_t buffer_size;
+	int ret;
 
 	f->bytes_per_block = archive_write_get_bytes_per_block(f->archive);
 	f->bytes_in_last_block =
@@ -363,7 +364,13 @@ archive_write_client_open(struct archive_write_filter 
 
 	if (a->client_opener == NULL)
 		return (ARCHIVE_OK);
-	return (a->client_opener(f->archive, a->client_data));
+	ret = a->client_opener(f->archive, a->client_data);
+	if (ret != ARCHIVE_OK) {
+		free(state->buffer);
+		free(state);
+		f->data = NULL;
+	}
+	return (ret);
 }
 
 static int
@@ -449,30 +456,6 @@ archive_write_client_write(struct archive_write_filter
 }
 
 static int
-archive_write_client_free(struct archive_write_filter *f)
-{
-	struct archive_write *a = (struct archive_write *)f->archive;
-	struct archive_none *state = (struct archive_none *)f->data;
-
-	if (state != NULL) {
-		free(state->buffer);
-		free(state);
-		state = NULL;
-	}
-
-	a->client_data = NULL;
-	/* Clear passphrase. */
-	if (a->passphrase != NULL) {
-		memset(a->passphrase, 0, strlen(a->passphrase));
-		free(a->passphrase);
-		a->passphrase = NULL;
-	}
-
-	return (ARCHIVE_OK);
-}
-
-
-static int
 archive_write_client_close(struct archive_write_filter *f)
 {
 	struct archive_write *a = (struct archive_write *)f->archive;
@@ -508,7 +491,15 @@ archive_write_client_close(struct archive_write_filter
 	}
 	if (a->client_closer)
 		(*a->client_closer)(&a->archive, a->client_data);
-
+	free(state->buffer);
+	free(state);
+	a->client_data = NULL;
+	/* Clear passphrase. */
+	if (a->passphrase != NULL) {
+		memset(a->passphrase, 0, strlen(a->passphrase));
+		free(a->passphrase);
+		a->passphrase = NULL;
+	}
 	/* Clear the close handler myself not to be called again. */
 	f->state = ARCHIVE_WRITE_FILTER_STATE_CLOSED;
 	return (ret);
@@ -539,7 +530,6 @@ archive_write_open(struct archive *_a, void *client_da
 	client_filter->open = archive_write_client_open;
 	client_filter->write = archive_write_client_write;
 	client_filter->close = archive_write_client_close;
-	client_filter->free = archive_write_client_free;
 
 	ret = __archive_write_filters_open(a);
 	if (ret < ARCHIVE_WARN) {


More information about the svn-src-head mailing list