aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2020-01-06 13:13:58 +0000
committerMartin Matuska <mm@FreeBSD.org>2020-01-06 13:13:58 +0000
commit98c1f51f769841d99d879099f9075ff60d51ee4a (patch)
tree5c37b2d4237050bfe30c0d68e30ce55b63f7aadb
parentcbda686f2407316625c3baf89f5071f0118f030b (diff)
downloadsrc-98c1f51f769841d99d879099f9075ff60d51ee4a.tar.gz
src-98c1f51f769841d99d879099f9075ff60d51ee4a.zip
Update vendor/libarchive/dist to git 3f1bad815d02160ab27f7063257aed4b25dbaebe
Relevant vendor changes: Issue #1302: Re-do fix for archive_write_client_open()
Notes
Notes: svn path=/vendor/libarchive/dist/; revision=356415
-rw-r--r--libarchive/archive_cryptor.c1
-rw-r--r--libarchive/archive_hmac.c1
-rw-r--r--libarchive/archive_write.c44
3 files changed, 19 insertions, 27 deletions
diff --git a/libarchive/archive_cryptor.c b/libarchive/archive_cryptor.c
index 769756d0b5ab..8ab2b0979676 100644
--- a/libarchive/archive_cryptor.c
+++ b/libarchive/archive_cryptor.c
@@ -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)
{
diff --git a/libarchive/archive_hmac.c b/libarchive/archive_hmac.c
index 68f2bb55dc04..2a9d04c8d8f1 100644
--- a/libarchive/archive_hmac.c
+++ b/libarchive/archive_hmac.c
@@ -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)
{
diff --git a/libarchive/archive_write.c b/libarchive/archive_write.c
index afa26b8ea0ed..98a55fb2aa00 100644
--- a/libarchive/archive_write.c
+++ b/libarchive/archive_write.c
@@ -339,6 +339,7 @@ archive_write_client_open(struct archive_write_filter *f)
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 *f)
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 *f,
}
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 *f)
}
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_data,
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) {