Skip to contentSkip to conversation

pkcs11_openssl.c: check EVP_get_digestbyname() != NULL

PATCH In review [email protected]... 3 participants 3 messages Jan 27, 2022 – Feb 3, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pkcs11_openssl.c: check EVP_get_digestbyname() != NULL

From: Selva Nair <[email protected]...>

---
 src/openvpn/pkcs11_openssl.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
src/openvpn/pkcs11_openssl.c +8 -1
index a82b4b32..c4f88816 100644
@@ -89,7 +89,14 @@ set_pss_params(CK_RSA_PKCS_PSS_PARAMS *pss_params, XKEY_SIGALG sigalg,
     pss_params->mgf = mdtypes[i].mgf_id;
 
     /* determine salt length */
-    int mdsize = EVP_MD_size(EVP_get_digestbyname(sigalg.mdname));
+    const EVP_MD *md = EVP_get_digestbyname(sigalg.mdname);
+    if (!md)
+    {
+        msg(M_WARN, "WARN: set_pss_params: EVP_get_digestbyname returned NULL "
+                    "for mdname = <%s>", sigalg.mdname);
+        goto cleanup;
+    }
+    int mdsize = EVP_MD_get_size(md);
 
     int saltlen = -1;
     if (!strcmp(sigalg.saltlen, "digest")) /* same as digest size */
Signature · 1 line
2.30.2
#2 lore raw
In reply to [email protected]...

Have not tested, but looks reasonable.

Your patch has been applied to the master branch.

commit fb60a5a9d0da982df0edeac8287aa5ee55f4e79a

Author: Selva Nair
Date:   Wed Jan 26 19:14:10 2022 -0500
     pkcs11_openssl.c: check EVP_get_digestbyname() != NULL

     Signed-off-by: Selva Nair <[email protected]...>
     Acked-by: Antonio Quartulli <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg23680.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering