Fix CID : Null pointer dereference in EVP_PKEY_CTX_ctrl() due to new call to evp_pkey_ctx_store_cached_data()
@@ -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);
}
