]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Remove OpenSSL compat code that misuses the API 1621/head
authorTheo Buehler <tb@openbsd.org>
Fri, 19 Nov 2021 17:55:29 +0000 (18:55 +0100)
committerTheo Buehler <tb@openbsd.org>
Sat, 20 Nov 2021 08:09:11 +0000 (09:09 +0100)
Immediately after EVP_CIPHER_CTX_new() neither EVP_CIPHER_CTX_init()
nor EVP_CIHPER_CTX_reset() should be called: the purpose of the init
function is to initialize a context on the stack while reset clears
a used context for reuse. Neither situation is the case here.

Removing the code also fixes a potential NULL dereference because an
error of reset is not signaled to the caller. Fortunately reset doesn't
currently fail in this situation in current OpenSSL and LibreSSL.

libarchive/archive_cryptor.c

index d4bca906b6ee95c00e71561404ba939a91f40e81..112baf1613482afc2ff716fa362a6c9f1d9022f9 100644 (file)
@@ -401,14 +401,6 @@ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
        memcpy(ctx->key, key, key_len);
        memset(ctx->nonce, 0, sizeof(ctx->nonce));
        ctx->encr_pos = AES_BLOCK_SIZE;
-#if OPENSSL_VERSION_NUMBER  >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
-       if (!EVP_CIPHER_CTX_reset(ctx->ctx)) {
-               EVP_CIPHER_CTX_free(ctx->ctx);
-               ctx->ctx = NULL;
-       }
-#else
-       EVP_CIPHER_CTX_init(ctx->ctx);
-#endif
        return 0;
 }