From 00d5193b688019a85d1bd0196f2837a4476394bb Mon Sep 17 00:00:00 2001 From: Peiwei Hu Date: Tue, 24 May 2022 23:40:12 +0800 Subject: [PATCH] Fix the check of evp_pkey_ctx_set_params_strict Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/18399) --- crypto/rsa/rsa_lib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c index 7eee218f8a7..9588a759649 100644 --- a/crypto/rsa/rsa_lib.c +++ b/crypto/rsa/rsa_lib.c @@ -1084,6 +1084,7 @@ int EVP_PKEY_CTX_get_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD **md) int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *ctx, void *label, int llen) { OSSL_PARAM rsa_params[2], *p = rsa_params; + int ret; if (ctx == NULL || !EVP_PKEY_CTX_IS_ASYM_CIPHER_OP(ctx)) { ERR_raise(ERR_LIB_EVP, EVP_R_COMMAND_NOT_SUPPORTED); @@ -1100,8 +1101,9 @@ int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *ctx, void *label, int llen) (void *)label, (size_t)llen); *p++ = OSSL_PARAM_construct_end(); - if (!evp_pkey_ctx_set_params_strict(ctx, rsa_params)) - return 0; + ret = evp_pkey_ctx_set_params_strict(ctx, rsa_params); + if (ret <= 0) + return ret; /* Ownership is supposed to be transferred to the callee. */ OPENSSL_free(label); -- 2.47.2