[pkg-opensc-commit] [libp11] 49/86: Context and module initialization fixes
Eric Dorland
eric at moszumanska.debian.org
Sun Jul 24 21:40:21 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 799c860d48fc9e045bfd6373ea48be12353bc38e
Author: Michał Trojnara <Michal.Trojnara at stunnel.org>
Date: Thu Feb 11 19:55:21 2016 +0100
Context and module initialization fixes
---
src/libp11-int.h | 4 +---
src/p11_front.c | 2 +-
src/p11_load.c | 14 ++++----------
3 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/src/libp11-int.h b/src/libp11-int.h
index e58fe85..6684e06 100644
--- a/src/libp11-int.h
+++ b/src/libp11-int.h
@@ -38,10 +38,8 @@ extern CK_RV C_UnloadModule(void *module);
* PKCS11_CTX: context for a PKCS11 implementation
*/
typedef struct pkcs11_ctx_private {
- char *name;
- void *libinfo;
CK_FUNCTION_LIST_PTR method;
-
+ void *handle;
char *init_args;
unsigned int forkid;
int lockid;
diff --git a/src/p11_front.c b/src/p11_front.c
index 0381e83..da72cb1 100644
--- a/src/p11_front.c
+++ b/src/p11_front.c
@@ -166,7 +166,7 @@ static int check_cert_fork(PKCS11_CERT *cert)
/* External interface to the libp11 features */
-PKCS11_CTX *pkcs11_CTX_new(void)
+PKCS11_CTX *PKCS11_CTX_new(void)
{
return pkcs11_CTX_new();
}
diff --git a/src/p11_load.c b/src/p11_load.c
index e66c266..45d2f7a 100644
--- a/src/p11_load.c
+++ b/src/p11_load.c
@@ -19,12 +19,10 @@
#include "libp11-int.h"
#include <string.h>
-static void *handle = NULL;
-
/*
* Create a new context
*/
-PKCS11_CTX *PKCS11_CTX_new(void)
+PKCS11_CTX *pkcs11_CTX_new(void)
{
PKCS11_CTX_private *cpriv = NULL;
PKCS11_CTX *ctx = NULL;
@@ -75,12 +73,8 @@ int pkcs11_CTX_load(PKCS11_CTX * ctx, const char *name)
CK_INFO ck_info;
int rv;
- if (cpriv->libinfo != NULL) {
- PKCS11err(PKCS11_F_PKCS11_CTX_LOAD, PKCS11_MODULE_LOADED_ERROR);
- return -1;
- }
- handle = C_LoadModule(name, &cpriv->method);
- if (handle == NULL) {
+ cpriv->handle = C_LoadModule(name, &cpriv->method);
+ if (cpriv->handle == NULL) {
PKCS11err(PKCS11_F_PKCS11_CTX_LOAD, PKCS11_LOAD_MODULE_ERROR);
return -1;
}
@@ -151,7 +145,7 @@ void pkcs11_CTX_unload(PKCS11_CTX * ctx)
cpriv->method->C_Finalize(NULL);
/* Unload the module */
- C_UnloadModule(handle);
+ C_UnloadModule(cpriv->handle);
}
/*
--
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