[pkg-opensc-commit] [libp11] 193/239: Avoid deadlock in PKCS11_open_session
Eric Dorland
eric at moszumanska.debian.org
Sat Oct 17 06:21:32 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 0a20a76b60d53fa2552a745ef7c53db9618d32d0
Author: Nikos Mavrogiannopoulos <nmav at redhat.com>
Date: Fri Jun 26 15:20:14 2015 +0200
Avoid deadlock in PKCS11_open_session
---
src/p11_slot.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/p11_slot.c b/src/p11_slot.c
index 8adc107..e01780e 100644
--- a/src/p11_slot.c
+++ b/src/p11_slot.c
@@ -108,17 +108,20 @@ PKCS11_SLOT *PKCS11_find_token(PKCS11_CTX * ctx, PKCS11_SLOT * slots, unsigned
/*
* Open a session with this slot
*/
-int PKCS11_open_session(PKCS11_SLOT * slot, int rw)
+static
+int PKCS11_open_session_int(PKCS11_SLOT * slot, int rw, int relogin)
{
PKCS11_SLOT_private *priv = PRIVSLOT(slot);
PKCS11_CTX *ctx = SLOT2CTX(slot);
int rv;
- CHECK_SLOT_FORK(slot);
+ if (relogin == 0) {
+ CHECK_SLOT_FORK(slot);
- if (priv->haveSession) {
- CRYPTOKI_call(ctx, C_CloseSession(priv->session));
- priv->haveSession = 0;
+ if (priv->haveSession) {
+ CRYPTOKI_call(ctx, C_CloseSession(priv->session));
+ priv->haveSession = 0;
+ }
}
rv = CRYPTOKI_call(ctx,
C_OpenSession(priv->id,
@@ -132,6 +135,11 @@ int PKCS11_open_session(PKCS11_SLOT * slot, int rw)
return 0;
}
+int PKCS11_open_session(PKCS11_SLOT * slot, int rw)
+{
+ return PKCS11_open_session_int(slot, rw, 0);
+}
+
int PKCS11_reopen_session(PKCS11_SLOT * slot)
{
PKCS11_SLOT_private *priv = PRIVSLOT(slot);
@@ -176,7 +184,7 @@ int PKCS11_login_int(PKCS11_SLOT * slot, int so, const char *pin, int relogin)
if (!priv->haveSession) {
/* SO gets a r/w session by default,
* user gets a r/o session by default. */
- if (PKCS11_open_session(slot, so))
+ if (PKCS11_open_session_int(slot, so, relogin))
return -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