From: Tomas Mraz Date: Thu, 28 Apr 2022 15:04:05 +0000 (+0200) Subject: fix_dh_paramgen_type: Avoid crash with invalid paramgen type X-Git-Tag: openssl-3.2.0-alpha1~2725 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=359dad5178285d5471f2a57a5aa99c1f588dffcb;p=thirdparty%2Fopenssl.git fix_dh_paramgen_type: Avoid crash with invalid paramgen type Reviewed-by: Dmitry Belyavskiy Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/18202) --- diff --git a/crypto/evp/ctrl_params_translate.c b/crypto/evp/ctrl_params_translate.c index 74df2fd1a30..08137ab256a 100644 --- a/crypto/evp/ctrl_params_translate.c +++ b/crypto/evp/ctrl_params_translate.c @@ -1072,7 +1072,11 @@ static int fix_dh_paramgen_type(enum state state, return 0; if (state == PRE_CTRL_STR_TO_PARAMS) { - ctx->p2 = (char *)ossl_dh_gen_type_id2name(atoi(ctx->p2)); + if ((ctx->p2 = (char *)ossl_dh_gen_type_id2name(atoi(ctx->p2))) + == NULL) { + ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_VALUE); + return 0; + } ctx->p1 = strlen(ctx->p2); }