From: Aki Tuomi Date: Tue, 22 Aug 2023 05:59:20 +0000 (+0300) Subject: lib-dcrypt: Ensure param is found in dcrypt_openssl_private_to_public_key X-Git-Tag: 2.4.0~2617 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75329443d9b3867a9347ce4adc4c6e1014b47da5;p=thirdparty%2Fdovecot%2Fcore.git lib-dcrypt: Ensure param is found in dcrypt_openssl_private_to_public_key --- diff --git a/src/lib-dcrypt/dcrypt-openssl3.c b/src/lib-dcrypt/dcrypt-openssl3.c index 86fdea9cb0..e0d2f897df 100644 --- a/src/lib-dcrypt/dcrypt-openssl3.c +++ b/src/lib-dcrypt/dcrypt-openssl3.c @@ -2585,10 +2585,12 @@ dcrypt_openssl_private_to_public_key(struct dcrypt_private_key *priv_key, i_assert(pk != NULL); /* we shouldn't get malloc() failures */ OSSL_PARAM *params = NULL; - EVP_PKEY_todata(pkey, EVP_PKEY_PUBLIC_KEY, ¶ms); + if (EVP_PKEY_todata(pkey, EVP_PKEY_PUBLIC_KEY, ¶ms) == 0) + i_unreached(); /* keep the key format compressed */ OSSL_PARAM *param = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_EC_POINT_CONVERSION_FORMAT); - OSSL_PARAM_set_utf8_string(param, "compressed"); + if (param != NULL) + OSSL_PARAM_set_utf8_string(param, "compressed"); EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_from_pkey(NULL, pkey, NULL); if (EVP_PKEY_fromdata_init(ctx) < 1 || EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_PUBLIC_KEY, params) < 1) {