openssl-pkcs11/SOURCES/openssl-pkcs11-0.4.8-error-handling-evp-pkey-set1-engine.patch
2021-09-09 23:19:57 +00:00

32 lines
931 B
Diff

From f41dba3102f4257fe366adf4cd8f0a0088c9b3f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Trojnara?= <Michal.Trojnara@stunnel.org>
Date: Thu, 23 Aug 2018 22:27:55 +0200
Subject: [PATCH 04/23] Error handling for EVP_PKEY_set1_engine()
---
src/eng_front.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/eng_front.c b/src/eng_front.c
index 853fa5a..5fe8f55 100644
--- a/src/eng_front.c
+++ b/src/eng_front.c
@@ -233,8 +233,12 @@ static EVP_PKEY *load_privkey(ENGINE *engine, const char *s_key_id,
#ifdef EVP_F_EVP_PKEY_SET1_ENGINE
/* EVP_PKEY_set1_engine() is required for OpenSSL 1.1.x,
* but otherwise setting pkey->engine breaks OpenSSL 1.0.2 */
- if (pkey)
- EVP_PKEY_set1_engine(pkey, engine);
+ if (pkey) {
+ if (!EVP_PKEY_set1_engine(pkey, engine)) {
+ EVP_PKEY_free(pkey);
+ return NULL;
+ }
+ }
#endif /* EVP_F_EVP_PKEY_SET1_ENGINE */
return pkey;
}
--
2.17.1