[pkg-opensc-commit] [libp11] 50/67: Plugged another memory leak

Eric Dorland eric at moszumanska.debian.org
Sat Jan 30 05:34:16 UTC 2016


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

eric pushed a commit to branch master
in repository libp11.

commit 39c15d86abb883dce367a9ace3e12cca88c30d66
Author: Michał Trojnara <Michal.Trojnara at stunnel.org>
Date:   Sun Jan 10 14:51:31 2016 +0100

    Plugged another memory leak
---
 src/p11_rsa.c  | 7 +++++--
 src/p11_slot.c | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/p11_rsa.c b/src/p11_rsa.c
index 4283e23..69e6053 100644
--- a/src/p11_rsa.c
+++ b/src/p11_rsa.c
@@ -49,9 +49,12 @@ static RSA *pkcs11_get_rsa(PKCS11_KEY * key)
 		RSA_free(rsa);
 		return NULL;
 	}
-
 	if(!BN_is_zero(rsa->e)) /* The public exponent was retrieved */
 		return rsa;
+	BN_clear_free(rsa->e);
+	/* In case someone modifies this function to execute RSA_free()
+	 * before a valid BN value is assigned to rsa->e */
+	rsa->e = NULL;
 
 	/* The public exponent was not found in the private key:
 	 * retrieve it from the corresponding public key */
@@ -235,7 +238,7 @@ RSA_METHOD *PKCS11_get_rsa_method(void)
 /* This function is *not* currently exported */
 void PKCS11_rsa_method_free(void)
 {
-    free_rsa_ex_index();
+	free_rsa_ex_index();
 }
 
 PKCS11_KEY_ops pkcs11_rsa_ops = {
diff --git a/src/p11_slot.c b/src/p11_slot.c
index 34fb930..bba41e7 100644
--- a/src/p11_slot.c
+++ b/src/p11_slot.c
@@ -235,7 +235,7 @@ int pkcs11_login(PKCS11_SLOT * slot, int so, const char *pin, int relogin)
 	rv = CRYPTOKI_call(ctx,
 		C_Login(priv->session, so ? CKU_SO : CKU_USER,
 			(CK_UTF8CHAR *) pin, pin ? strlen(pin) : 0));
-	if (rv && rv != CKR_USER_ALREADY_LOGGED_IN)  /* logged in -> OK   */
+	if (rv && rv != CKR_USER_ALREADY_LOGGED_IN) /* logged in -> OK */
 		CRYPTOKI_checkerr(PKCS11_F_PKCS11_LOGIN, rv);
 	priv->loggedIn = 1;
 

-- 
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