[pkg-opensc-commit] [libp11] 15/67: Reinitialize the PKCS11 internal slot table in PKCS11_CTX_reload
Eric Dorland
eric at moszumanska.debian.org
Sat Jan 30 05:34:13 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 e52e6ff7831052d1f392ad354dfb21cf247d49d9
Author: Michał Trojnara <Michal.Trojnara at mirt.net>
Date: Tue Dec 15 12:57:27 2015 +0100
Reinitialize the PKCS11 internal slot table in PKCS11_CTX_reload
---
src/libp11-int.h | 1 +
src/p11_load.c | 3 ++-
src/p11_slot.c | 17 +++++++++++++----
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/src/libp11-int.h b/src/libp11-int.h
index 344e7f1..168b48f 100644
--- a/src/libp11-int.h
+++ b/src/libp11-int.h
@@ -178,6 +178,7 @@ typedef struct pkcs11_cert_private {
#define PKCS11_DUP(s) \
pkcs11_strdup((char *) s, sizeof(s))
+extern int pkcs11_enumerate_slots(PKCS11_CTX *, PKCS11_SLOT **, unsigned int *);
extern void pkcs11_release_slot(PKCS11_CTX *, PKCS11_SLOT *slot);
extern void pkcs11_destroy_keys(PKCS11_TOKEN *);
diff --git a/src/p11_load.c b/src/p11_load.c
index afc37c2..f2a65ff 100644
--- a/src/p11_load.c
+++ b/src/p11_load.c
@@ -129,7 +129,8 @@ int PKCS11_CTX_reload(PKCS11_CTX * ctx)
return -1;
}
- return 0;
+ /* Reinitialize the PKCS11 internal slot table */
+ return pkcs11_enumerate_slots(ctx, NULL, NULL);
}
/*
diff --git a/src/p11_slot.c b/src/p11_slot.c
index 7269229..40a7972 100644
--- a/src/p11_slot.c
+++ b/src/p11_slot.c
@@ -42,14 +42,19 @@ PKCS11_get_slotid_from_slot(PKCS11_SLOT *slot)
int
PKCS11_enumerate_slots(PKCS11_CTX * ctx, PKCS11_SLOT ** slotp, unsigned int *countp)
{
+ CHECK_FORK(ctx);
+ return pkcs11_enumerate_slots(ctx, slotp, countp);
+}
+
+int
+pkcs11_enumerate_slots(PKCS11_CTX * ctx, PKCS11_SLOT ** slotp, unsigned int *countp)
+{
PKCS11_CTX_private *priv;
CK_SLOT_ID *slotid;
CK_ULONG nslots, n;
PKCS11_SLOT *slots;
int rv;
- CHECK_FORK(ctx);
-
priv = PRIVCTX(ctx);
rv = priv->method->C_GetSlotList(FALSE, NULL_PTR, &nslots);
@@ -72,8 +77,12 @@ PKCS11_enumerate_slots(PKCS11_CTX * ctx, PKCS11_SLOT ** slotp, unsigned int *cou
}
}
- *slotp = slots;
- *countp = nslots;
+ if (slotp)
+ *slotp = slots;
+ else
+ OPENSSL_free(slots);
+ if (countp)
+ *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