From: Max Ammann Date: Tue, 7 May 2024 22:06:39 +0000 (+0100) Subject: EVP_CIPHER_CTX_get_key_length(): Add null check of ctx->cipher X-Git-Tag: openssl-3.4.0-alpha1~524 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46f55238d2dc39725873de308e1e727556cb33bd;p=thirdparty%2Fopenssl.git EVP_CIPHER_CTX_get_key_length(): Add null check of ctx->cipher Reviewed-by: Matt Caswell Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/22964) --- diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index be95668c7e1..e80c2ba6812 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -670,6 +670,9 @@ int EVP_CIPHER_get_key_length(const EVP_CIPHER *cipher) int EVP_CIPHER_CTX_get_key_length(const EVP_CIPHER_CTX *ctx) { + if (ctx->cipher == NULL) + return 0; + if (ctx->key_len <= 0 && ctx->cipher->prov != NULL) { int ok; OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };