diff options
author | Martin Willi <martin@revosec.ch> | 2010-11-18 08:43:26 +0100 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2010-11-18 08:44:22 +0100 |
commit | cfa18d14f1281c3f58591eda643a81ef07ba08dd (patch) | |
tree | b0cb5ae38915538b11b434daa5c7c4d030eb8e41 | |
parent | 0ebff9f44241f2ec30d3e5302e7af6db745f8f3d (diff) | |
download | strongswan-cfa18d14f1281c3f58591eda643a81ef07ba08dd.tar.bz2 strongswan-cfa18d14f1281c3f58591eda643a81ef07ba08dd.tar.xz |
Use static args for C_Initialize(), OpenSC does not get a copy of the pointers
-rw-r--r-- | src/libstrongswan/plugins/pkcs11/pkcs11_library.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_library.c b/src/libstrongswan/plugins/pkcs11/pkcs11_library.c index 437364781..e5af0c292 100644 --- a/src/libstrongswan/plugins/pkcs11/pkcs11_library.c +++ b/src/libstrongswan/plugins/pkcs11/pkcs11_library.c @@ -806,12 +806,15 @@ static bool initialize(private_pkcs11_library_t *this, char *name, char *file, CK_C_GetFunctionList pC_GetFunctionList; CK_INFO info; CK_RV rv; - CK_C_INITIALIZE_ARGS args = { + static CK_C_INITIALIZE_ARGS args = { .CreateMutex = CreateMutex, .DestroyMutex = DestroyMutex, .LockMutex = LockMutex, .UnlockMutex = UnlockMutex, }; + static CK_C_INITIALIZE_ARGS args_os = { + .flags = CKF_OS_LOCKING_OK, + }; pC_GetFunctionList = dlsym(this->handle, "C_GetFunctionList"); if (!pC_GetFunctionList) @@ -836,9 +839,8 @@ static bool initialize(private_pkcs11_library_t *this, char *name, char *file, } if (rv == CKR_CANT_LOCK) { /* fallback to OS locking */ - memset(&args, 0, sizeof(args)); - args.flags = CKF_OS_LOCKING_OK; - rv = this->public.f->C_Initialize(&args); + os_locking = TRUE; + rv = this->public.f->C_Initialize(&args_os); } if (rv != CKR_OK) { @@ -865,7 +867,7 @@ static bool initialize(private_pkcs11_library_t *this, char *name, char *file, DBG1(DBG_CFG, " %s: %s v%d.%d", info.manufacturerID, info.libraryDescription, info.libraryVersion.major, info.libraryVersion.minor); - if (args.flags & CKF_OS_LOCKING_OK) + if (os_locking) { DBG1(DBG_CFG, " uses OS locking functions"); } |