From 7a88ff4d87a5a5f267a9ae93a36b13c419a6c1f5 Mon Sep 17 00:00:00 2001 From: nils Date: Tue, 8 Jun 2004 20:22:36 +0000 Subject: [PATCH] fix module name handling patch supplied by Michael Bell git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1788 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/sslengines/engine_pkcs11.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/sslengines/engine_pkcs11.c b/src/sslengines/engine_pkcs11.c index 10d7d03a..13f520a7 100644 --- a/src/sslengines/engine_pkcs11.c +++ b/src/sslengines/engine_pkcs11.c @@ -38,11 +38,13 @@ PKCS11_CTX *ctx; char *pin = NULL; int quiet = 1; -const char *module = PKCS11_DEFAULT_MODULE_NAME; +char *module = PKCS11_DEFAULT_MODULE_NAME; +int default_module = 1; int set_module(const char *modulename) { - module = modulename; + module = strdup (modulename); + default_module = 0; return 1; } @@ -92,7 +94,7 @@ int pkcs11_init(ENGINE * engine) } ctx = PKCS11_CTX_new(); if (PKCS11_CTX_load(ctx, module) < 0) { - fprintf(stderr, "unable to load module\n"); + fprintf(stderr, "unable to load module %s\n", module); return 0; } return 1; @@ -103,6 +105,9 @@ int pkcs11_rsa_finish(RSA * rsa) if (pin) { free(pin); } + if (!default_module && module) { + free(module); + } /* need to free RSA_ex_data? */ return 1; }