]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
EVP_CIPHER_CTX_get_key_length(): Add null check of ctx->cipher
authorMax Ammann <max@maxammann.org>
Tue, 7 May 2024 22:06:39 +0000 (23:06 +0100)
committerTomas Mraz <tomas@openssl.org>
Fri, 24 May 2024 09:57:10 +0000 (11:57 +0200)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22964)

crypto/evp/evp_lib.c

index be95668c7e197b124cd57ff9d71bd7a5e83f5d66..e80c2ba681268a71f3336bf412224e0f2dd64320 100644 (file)
@@ -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 };