[pkg-opensc-commit] [libp11] 83/239: dynamically allocate slots, as suggested by Thomas Irlet

Eric Dorland eric at moszumanska.debian.org
Sat Oct 17 06:21:12 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 4e693eba0afc4d8feb27cdd7f511c954baa11a1a
Author: Andreas Jellinghaus <andreas at ionisiert.de>
Date:   Tue Apr 18 15:17:19 2006 +0000

    dynamically allocate slots, as suggested by Thomas Irlet
---
 src/p11_slot.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/p11_slot.c b/src/p11_slot.c
index 3df9d50..1e92c15 100644
--- a/src/p11_slot.c
+++ b/src/p11_slot.c
@@ -32,11 +32,17 @@ PKCS11_enumerate_slots(PKCS11_CTX * ctx, PKCS11_SLOT ** slotp, unsigned int *cou
 {
 	PKCS11_CTX_private *priv = PRIVCTX(ctx);
 
-	CK_SLOT_ID slotid[64];
-	CK_ULONG nslots = sizeof(slotid), n;
+	CK_SLOT_ID *slotid;
+	CK_ULONG nslots, n;
 	PKCS11_SLOT *slots;
 	int rv;
 
+	rv = priv->method->C_GetSlotList(FALSE, NULL_PTR, &nslots);
+	CRYPTOKI_checkerr(PKCS11_F_PKCS11_ENUM_SLOTS, rv);
+
+	slotid = (CK_SLOT_ID *)OPENSSL_malloc(nslots * sizeof(CK_SLOT_ID));
+	if (slotid == NULL) return (-1);
+
 	rv = priv->method->C_GetSlotList(FALSE, slotid, &nslots);
 	CRYPTOKI_checkerr(PKCS11_F_PKCS11_ENUM_SLOTS, rv);
 
@@ -45,6 +51,7 @@ PKCS11_enumerate_slots(PKCS11_CTX * ctx, PKCS11_SLOT ** slotp, unsigned int *cou
 		if (pkcs11_init_slot(ctx, &slots[n], slotid[n])) {
 			while (n--)
 				pkcs11_release_slot(ctx, slots + n);
+			OPENSSL_free(slotid);
 			OPENSSL_free(slots);
 			return -1;
 		}
@@ -52,6 +59,7 @@ PKCS11_enumerate_slots(PKCS11_CTX * ctx, PKCS11_SLOT ** slotp, unsigned int *cou
 
 	*slotp = slots;
 	*countp = nslots;
+	OPENSSL_free(slotid);
 	return 0;
 }
 

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