From acd1d96d3e0df583ab661943bb1ffb93a8000dd5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 6 Dec 2016 11:35:14 -0500 Subject: [PATCH] Check for EVP_CIPHER_CTX_new failure (#836) If this OpenSSL function fails to allocate memory it returns NULL. --- libarchive/archive_cryptor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libarchive/archive_cryptor.c b/libarchive/archive_cryptor.c index 2a51dfe1d..ced52fd70 100644 --- a/libarchive/archive_cryptor.c +++ b/libarchive/archive_cryptor.c @@ -302,7 +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) { - ctx->ctx = EVP_CIPHER_CTX_new(); + if ((ctx->ctx = EVP_CIPHER_CTX_new()) == NULL) + return -1; switch (key_len) { case 16: ctx->type = EVP_aes_128_ecb(); break; -- 2.47.2