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

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