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
This commit is contained in:
commit
759a578b0c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=356416
@ -299,6 +299,7 @@ aes_ctr_release(archive_crypto_ctx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_AES_H)
|
#elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_AES_H)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
||||||
{
|
{
|
||||||
|
@ -151,6 +151,7 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_MD_H)
|
#elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_MD_H)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
|
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
|
||||||
{
|
{
|
||||||
|
@ -339,6 +339,7 @@ archive_write_client_open(struct archive_write_filter *f)
|
|||||||
struct archive_none *state;
|
struct archive_none *state;
|
||||||
void *buffer;
|
void *buffer;
|
||||||
size_t buffer_size;
|
size_t buffer_size;
|
||||||
|
int ret;
|
||||||
|
|
||||||
f->bytes_per_block = archive_write_get_bytes_per_block(f->archive);
|
f->bytes_per_block = archive_write_get_bytes_per_block(f->archive);
|
||||||
f->bytes_in_last_block =
|
f->bytes_in_last_block =
|
||||||
@ -363,7 +364,13 @@ archive_write_client_open(struct archive_write_filter *f)
|
|||||||
|
|
||||||
if (a->client_opener == NULL)
|
if (a->client_opener == NULL)
|
||||||
return (ARCHIVE_OK);
|
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
|
static int
|
||||||
@ -448,30 +455,6 @@ archive_write_client_write(struct archive_write_filter *f,
|
|||||||
return (ARCHIVE_OK);
|
return (ARCHIVE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
static int
|
||||||
archive_write_client_close(struct archive_write_filter *f)
|
archive_write_client_close(struct archive_write_filter *f)
|
||||||
{
|
{
|
||||||
@ -508,7 +491,15 @@ archive_write_client_close(struct archive_write_filter *f)
|
|||||||
}
|
}
|
||||||
if (a->client_closer)
|
if (a->client_closer)
|
||||||
(*a->client_closer)(&a->archive, a->client_data);
|
(*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. */
|
/* Clear the close handler myself not to be called again. */
|
||||||
f->state = ARCHIVE_WRITE_FILTER_STATE_CLOSED;
|
f->state = ARCHIVE_WRITE_FILTER_STATE_CLOSED;
|
||||||
return (ret);
|
return (ret);
|
||||||
@ -539,7 +530,6 @@ archive_write_open(struct archive *_a, void *client_data,
|
|||||||
client_filter->open = archive_write_client_open;
|
client_filter->open = archive_write_client_open;
|
||||||
client_filter->write = archive_write_client_write;
|
client_filter->write = archive_write_client_write;
|
||||||
client_filter->close = archive_write_client_close;
|
client_filter->close = archive_write_client_close;
|
||||||
client_filter->free = archive_write_client_free;
|
|
||||||
|
|
||||||
ret = __archive_write_filters_open(a);
|
ret = __archive_write_filters_open(a);
|
||||||
if (ret < ARCHIVE_WARN) {
|
if (ret < ARCHIVE_WARN) {
|
||||||
|
Loading…
Reference in New Issue
Block a user