[pkg-opensc-commit] [libp11] 163/239: Do not set private to C_Initialize unless actually have one
Eric Dorland
eric at moszumanska.debian.org
Sat Oct 17 06:21:27 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 9c837e4b1eb5eaf9b9c4a373ff5f9de1dfc4d63d
Author: Alon Bar-Lev <alon.barlev at gmail.com>
Date: Fri Jun 17 18:42:14 2011 +0000
Do not set private to C_Initialize unless actually have one
From: Jonathan Giannuzzi <jonathan at giannuzzi.be>
Date: Fri, Jun 17, 2011 at 2:55 PM
Subject: [opensc-devel] Patch for libp11 to fix compatibility with AET SafeSign PKCS#11 library
To: opensc-devel at lists.opensc-project.org
Hello,
When using libp11 to wrap around the AET SafeSign PKCS#11 library, C_GetInfo fails with CKR_MUTEX_BAD. This is because an empty CK_C_INITIALIZE_ARGS structure is passed to C_Initialize.
I made a change in PKCS11_CTX_load so that when no init_args have been set, no CK_C_INITIALIZE_ARGS is given to C_Initialize.
It should not break any other P11 library loading.
Cheers,
Jonathan
---
src/p11_load.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/p11_load.c b/src/p11_load.c
index 115f9f6..d315aa6 100644
--- a/src/p11_load.c
+++ b/src/p11_load.c
@@ -55,7 +55,8 @@ void PKCS11_CTX_init_args(PKCS11_CTX * ctx, const char *init_args)
int PKCS11_CTX_load(PKCS11_CTX * ctx, const char *name)
{
PKCS11_CTX_private *priv = PRIVCTX(ctx);
- CK_C_INITIALIZE_ARGS args;
+ CK_C_INITIALIZE_ARGS _args;
+ CK_C_INITIALIZE_ARGS *args = NULL;
CK_INFO ck_info;
int rv;
@@ -70,9 +71,12 @@ int PKCS11_CTX_load(PKCS11_CTX * ctx, const char *name)
}
/* Tell the PKCS11 to initialize itself */
- memset(&args, 0, sizeof(args));
- args.pReserved = priv->init_args;
- rv = priv->method->C_Initialize(&args);
+ if (priv->init_args != NULL) {
+ memset(&_args, 0, sizeof(_args));
+ args = &_args;
+ args->pReserved = priv->init_args;
+ }
+ rv = priv->method->C_Initialize(args);
if (rv && rv != CKR_CRYPTOKI_ALREADY_INITIALIZED) {
PKCS11err(PKCS11_F_PKCS11_CTX_LOAD, rv);
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