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