summaryrefslogtreecommitdiffstats
path: root/crypto/evp/pmeth_lib.c
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2020-09-21 10:59:20 +1000
committerShane Lontis <shane.lontis@oracle.com>2020-09-23 17:16:38 +1000
commitd65ab22efdc707a3b8747d8827e2a92eafeaf786 (patch)
tree518fec971dab73d76a4855ee79499db1719c1ae0 /crypto/evp/pmeth_lib.c
parent78ef571707eeb5c19ef86eafacf0e9867eb3174a (diff)
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 <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/12930)
Diffstat (limited to 'crypto/evp/pmeth_lib.c')
-rw-r--r--crypto/evp/pmeth_lib.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c
index 0d719943f0..26193cd644 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);
}