From: Pauli Date: Sun, 23 May 2021 22:59:36 +0000 (+1000) Subject: coverity 1484913: Null pointer dereferences (REVERSE_INULL) X-Git-Tag: openssl-3.0.0-beta1~347 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=29604f492020b76fde2665cde3f2a9c5adea3549;p=thirdparty%2Fopenssl.git coverity 1484913: Null pointer dereferences (REVERSE_INULL) Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15425) --- diff --git a/crypto/evp/p_seal.c b/crypto/evp/p_seal.c index 6a07737e590..c13041f027b 100644 --- a/crypto/evp/p_seal.c +++ b/crypto/evp/p_seal.c @@ -15,23 +15,28 @@ #include #include #include +#include int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek, int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk) { unsigned char key[EVP_MAX_KEY_LENGTH]; - const OSSL_PROVIDER *prov = EVP_CIPHER_provider(type); - OSSL_LIB_CTX *libctx = prov != NULL ? ossl_provider_libctx(prov) : NULL; + const OSSL_PROVIDER *prov; + OSSL_LIB_CTX *libctx = NULL; EVP_PKEY_CTX *pctx = NULL; + const EVP_CIPHER *cipher; int i, len; int rv = 0; - if (type) { + if (type != NULL) { EVP_CIPHER_CTX_reset(ctx); if (!EVP_EncryptInit_ex(ctx, type, NULL, NULL, NULL)) return 0; } + if ((cipher = EVP_CIPHER_CTX_get0_cipher(ctx)) != NULL + && (prov = EVP_CIPHER_provider(cipher)) != NULL) + libctx = ossl_provider_libctx(prov); if ((npubk <= 0) || !pubk) return 1;