summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPW Hu <jlu.hpw@foxmail.com>2021-10-08 16:59:00 +0800
committerTomas Mraz <tomas@openssl.org>2021-10-11 10:46:03 +0200
commit6e463bcd53fedbb4ec277a5eb885619e32adcdd2 (patch)
tree5d71a27a7dcf07664290debdb0e88acba0c23740
parentce5b392c8dc99f849dabea8bc9a21f66908b4188 (diff)
Bugfix: unsafe return check of EVP_PKEY_fromdata_init
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16783) (cherry picked from commit 5e199c356d09aca3b625b5ea16966b36d24b0201)
-rw-r--r--apps/dhparam.c2
-rw-r--r--crypto/evp/p_lib.c2
-rw-r--r--test/helpers/predefined_dhparams.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/apps/dhparam.c b/apps/dhparam.c
index 982b2db549..6b8546e93b 100644
--- a/apps/dhparam.c
+++ b/apps/dhparam.c
@@ -383,7 +383,7 @@ static EVP_PKEY *dsa_to_dh(EVP_PKEY *dh)
ctx = EVP_PKEY_CTX_new_from_name(NULL, "DHX", NULL);
if (ctx == NULL
- || !EVP_PKEY_fromdata_init(ctx)
+ || EVP_PKEY_fromdata_init(ctx) <= 0
|| !EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_KEY_PARAMETERS, params)) {
BIO_printf(bio_err, "Error, failed to set DH parameters\n");
goto err;
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index 2bc1237488..424d11b259 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -630,7 +630,7 @@ static EVP_PKEY *new_cmac_key_int(const unsigned char *priv, size_t len,
if (ctx == NULL)
goto err;
- if (!EVP_PKEY_fromdata_init(ctx)) {
+ if (EVP_PKEY_fromdata_init(ctx) <= 0) {
ERR_raise(ERR_LIB_EVP, EVP_R_KEY_SETUP_FAILED);
goto err;
}
diff --git a/test/helpers/predefined_dhparams.c b/test/helpers/predefined_dhparams.c
index a6dd8c08a5..b2f6601188 100644
--- a/test/helpers/predefined_dhparams.c
+++ b/test/helpers/predefined_dhparams.c
@@ -23,7 +23,7 @@ static EVP_PKEY *get_dh_from_pg_bn(OSSL_LIB_CTX *libctx, const char *type,
OSSL_PARAM *params = NULL;
EVP_PKEY *dhpkey = NULL;
- if (pctx == NULL || !EVP_PKEY_fromdata_init(pctx))
+ if (pctx == NULL || EVP_PKEY_fromdata_init(pctx) <= 0)
goto err;
if ((tmpl = OSSL_PARAM_BLD_new()) == NULL