From: Shane Lontis Date: Mon, 21 Sep 2020 00:59:20 +0000 (+1000) Subject: Fix CID 1466714 : Null pointer dereference in EVP_PKEY_CTX_ctrl() due to new call... X-Git-Tag: openssl-3.0.0-alpha7~150 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d65ab22efdc707a3b8747d8827e2a92eafeaf786;p=thirdparty%2Fopenssl.git Fix CID 1466714 : Null pointer dereference in EVP_PKEY_CTX_ctrl() due to new call to evp_pkey_ctx_store_cached_data() Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/12930) --- diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index 0d719943f07..26193cd6440 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -1450,11 +1450,6 @@ static int evp_pkey_ctx_ctrl_int(EVP_PKEY_CTX *ctx, int keytype, int optype, { int ret = 0; - if (ctx == NULL) { - EVPerr(0, EVP_R_COMMAND_NOT_SUPPORTED); - return -2; - } - /* * If the method has a |digest_custom| function, we can relax the * operation type check, since this can be called before the operation @@ -1498,6 +1493,10 @@ int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, { int ret = 0; + if (ctx == NULL) { + EVPerr(0, EVP_R_COMMAND_NOT_SUPPORTED); + return -2; + } /* If unsupported, we don't want that reported here */ ERR_set_mark(); ret = evp_pkey_ctx_store_cached_data(ctx, keytype, optype, @@ -1514,7 +1513,6 @@ int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, if (ret < 1 || ctx->operation == EVP_PKEY_OP_UNDEFINED) return ret; } - return evp_pkey_ctx_ctrl_int(ctx, keytype, optype, cmd, p1, p2); }