[pkg-opensc-commit] [libp11] 195/239: Added error checking in PKCS11_CTX_new()

Eric Dorland eric at moszumanska.debian.org
Sat Oct 17 06:21:33 UTC 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository libp11.

commit e5aa18c031e200701679c0c49ea49eced084bb22
Author: Nikos Mavrogiannopoulos <nmav at redhat.com>
Date:   Thu Jul 2 10:30:52 2015 +0200

    Added error checking in PKCS11_CTX_new()
---
 src/p11_load.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/p11_load.c b/src/p11_load.c
index 15cd0c1..a872345 100644
--- a/src/p11_load.c
+++ b/src/p11_load.c
@@ -27,22 +27,32 @@ static void *handle = NULL;
  */
 PKCS11_CTX *PKCS11_CTX_new(void)
 {
-	PKCS11_CTX_private *priv;
-	PKCS11_CTX *ctx;
+	PKCS11_CTX_private *priv = NULL;
+	PKCS11_CTX *ctx = NULL;
 
 	/* Load error strings */
 	ERR_load_PKCS11_strings();
 
 	priv = PKCS11_NEW(PKCS11_CTX_private);
+	if (priv == NULL)
+		goto fail;
 	ctx = PKCS11_NEW(PKCS11_CTX);
+	if (ctx == NULL)
+		goto fail;
 	ctx->_private = priv;
 	priv->forkid = _P11_get_forkid();
 
 #ifndef _WIN32
-	pthread_mutex_init(&priv->mutex, NULL);
+	if (pthread_mutex_init(&priv->mutex, NULL) != 0) {
+		goto fail;
+	}
 #endif
 
 	return ctx;
+ fail:
+	OPENSSL_free(priv);
+	OPENSSL_free(ctx);
+	return NULL;
 }
 
 /*

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/libp11.git



More information about the pkg-opensc-commit mailing list