Blame SOURCES/openssl-pkcs11-0.4.10-small-bug-fixes.patch

4daba6
From 987ad38fbb16e5c4fb2f7e8ba7be50f54d108417 Mon Sep 17 00:00:00 2001
4daba6
From: Henrik Riomar <henrik.riomar@gmail.com>
4daba6
Date: Wed, 10 Apr 2019 13:54:17 +0200
4daba6
Subject: [PATCH 1/3] add needed include for getpid()
4daba6
4daba6
Fixes:
4daba6
 p11_atfork.c: In function '_P11_get_forkid':
4daba6
 p11_atfork.c:78:9: warning: implicit declaration of function 'getpid'; did you mean 'getenv'? [-Wimplicit-function-declaration]
4daba6
  return getpid();
4daba6
(cherry picked from commit 97700cb51ac1e84f5ac8bc402e6f9e0fc271d76b)
4daba6
---
4daba6
 src/p11_atfork.c | 1 +
4daba6
 1 file changed, 1 insertion(+)
4daba6
4daba6
diff --git a/src/p11_atfork.c b/src/p11_atfork.c
4daba6
index 8fc8689..43c38f7 100644
4daba6
--- a/src/p11_atfork.c
4daba6
+++ b/src/p11_atfork.c
4daba6
@@ -23,6 +23,7 @@
4daba6
 #include "libp11-int.h"
4daba6
 
4daba6
 #ifndef _WIN32
4daba6
+#include <unistd.h>
4daba6
 
4daba6
 #ifndef __STDC_VERSION__
4daba6
 /* older than C90 */
4daba6
-- 
4daba6
2.21.0
4daba6
4daba6
4daba6
From 8103e98e452624e254beef0fd788f66d13fc8ae6 Mon Sep 17 00:00:00 2001
4daba6
From: ucq <ucq@cyberdefense.jp>
4daba6
Date: Tue, 14 May 2019 12:17:45 +0900
4daba6
Subject: [PATCH 2/3] fix use-after-free on PKCS11_pkey_meths.
4daba6
4daba6
(cherry picked from commit e64496a198d4d2eb0310a22dc21be8b81367d319)
4daba6
---
4daba6
 src/p11_pkey.c | 10 ++++------
4daba6
 1 file changed, 4 insertions(+), 6 deletions(-)
4daba6
4daba6
diff --git a/src/p11_pkey.c b/src/p11_pkey.c
4daba6
index 7eaf761..2995881 100644
4daba6
--- a/src/p11_pkey.c
4daba6
+++ b/src/p11_pkey.c
4daba6
@@ -666,8 +666,8 @@ int PKCS11_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth,
4daba6
 		EVP_PKEY_EC,
4daba6
 		0
4daba6
 	};
4daba6
-	static EVP_PKEY_METHOD *pkey_method_rsa = NULL;
4daba6
-	static EVP_PKEY_METHOD *pkey_method_ec = NULL;
4daba6
+	EVP_PKEY_METHOD *pkey_method_rsa = NULL;
4daba6
+	EVP_PKEY_METHOD *pkey_method_ec = NULL;
4daba6
 
4daba6
 	(void)e; /* squash the unused parameter warning */
4daba6
 	/* all PKCS#11 engines currently share the same pkey_meths */
4daba6
@@ -680,16 +680,14 @@ int PKCS11_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth,
4daba6
 	/* get the EVP_PKEY_METHOD */
4daba6
 	switch (nid) {
4daba6
 	case EVP_PKEY_RSA:
4daba6
-		if (pkey_method_rsa == NULL)
4daba6
-			pkey_method_rsa = pkcs11_pkey_method_rsa();
4daba6
+		pkey_method_rsa = pkcs11_pkey_method_rsa();
4daba6
 		if (pkey_method_rsa == NULL)
4daba6
 			return 0;
4daba6
 		*pmeth = pkey_method_rsa;
4daba6
 		return 1; /* success */
4daba6
 #ifndef OPENSSL_NO_EC
4daba6
 	case EVP_PKEY_EC:
4daba6
-		if (pkey_method_ec == NULL)
4daba6
-			pkey_method_ec = pkcs11_pkey_method_ec();
4daba6
+		pkey_method_ec = pkcs11_pkey_method_ec();
4daba6
 		if (pkey_method_ec == NULL)
4daba6
 			return 0;
4daba6
 		*pmeth = pkey_method_ec;
4daba6
-- 
4daba6
2.21.0
4daba6
4daba6
4daba6
From d24c5dfa149a15c002d202964c513624d7ae1380 Mon Sep 17 00:00:00 2001
4daba6
From: =?UTF-8?q?Micha=C5=82=20Trojnara?= <Michal.Trojnara@stunnel.org>
4daba6
Date: Wed, 14 Aug 2019 15:23:41 +0200
4daba6
Subject: [PATCH 3/3] Remove an unused variable
4daba6
4daba6
(cherry picked from commit 5d48d2ff75918409684a6aefe5b1f3e5d8ec7f0d)
4daba6
---
4daba6
 src/p11_pkey.c | 3 +--
4daba6
 1 file changed, 1 insertion(+), 2 deletions(-)
4daba6
4daba6
diff --git a/src/p11_pkey.c b/src/p11_pkey.c
4daba6
index 2995881..de0277e 100644
4daba6
--- a/src/p11_pkey.c
4daba6
+++ b/src/p11_pkey.c
4daba6
@@ -545,7 +545,7 @@ static int pkcs11_try_pkey_ec_sign(EVP_PKEY_CTX *evp_pkey_ctx,
4daba6
 
4daba6
 	ossl_sig = ECDSA_SIG_new();
4daba6
 	if (ossl_sig == NULL)
4daba6
-		return-1;
4daba6
+		return -1;
4daba6
 
4daba6
 	pkey = EVP_PKEY_CTX_get0_pkey(evp_pkey_ctx);
4daba6
 	if (pkey == NULL)
4daba6
@@ -578,7 +578,6 @@ static int pkcs11_try_pkey_ec_sign(EVP_PKEY_CTX *evp_pkey_ctx,
4daba6
 		return -1;
4daba6
 
4daba6
 	if (!cpriv->sign_initialized) {
4daba6
-		int padding;
4daba6
 		CK_MECHANISM mechanism;
4daba6
 		memset(&mechanism, 0, sizeof mechanism);
4daba6
 
4daba6
-- 
4daba6
2.21.0
4daba6