From 35bcac131ce5605c504d48a077f33f69660b660c Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Fri, 19 Aug 2022 12:28:42 +0200 Subject: [PATCH] rl->enc_ctx must be non-NULL and cipher must be set Otherwise ssl3_cipher() cannot work properly. Fixes Coverity CID 1509401 Reviewed-by: Paul Dale Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/19027) --- ssl/record/methods/ssl3_meth.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ssl/record/methods/ssl3_meth.c b/ssl/record/methods/ssl3_meth.c index 254e8cf1476..f1fd1f42031 100644 --- a/ssl/record/methods/ssl3_meth.c +++ b/ssl/record/methods/ssl3_meth.c @@ -98,10 +98,8 @@ static int ssl3_cipher(OSSL_RECORD_LAYER *rl, SSL3_RECORD *inrecs, size_t n_recs return 0; ds = rl->enc_ctx; - if (rl->enc_ctx == NULL) - enc = NULL; - else - enc = EVP_CIPHER_CTX_get0_cipher(rl->enc_ctx); + if (ds == NULL || (enc = EVP_CIPHER_CTX_get0_cipher(ds)) == NULL) + return 0; provided = (EVP_CIPHER_get0_provider(enc) != NULL); -- 2.47.2