From: Nikos Mavrogiannopoulos Date: Sat, 13 Aug 2011 08:02:15 +0000 (+0200) Subject: If a module is dlopened twice, then deinitialize the second load. X-Git-Tag: gnutls_3_0_1~13^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=94ea2f20dfc3ddb63006d42455fa75905d26bf8d;p=thirdparty%2Fgnutls.git If a module is dlopened twice, then deinitialize the second load. --- diff --git a/NEWS b/NEWS index f1581f3642..e4a2fbea88 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,9 @@ See the end for copying conditions. * Version 3.0.1 (unreleased) +** libgnutls: Do not allow second instances of PKCS #11 +modules. + ** libgnutls: fixed alignment issue in AES-NI code. ** libgnutls: The config file at gnutls_pkcs11_init() diff --git a/lib/pkcs11.c b/lib/pkcs11.c index f8be3344c6..9db09c50f3 100644 --- a/lib/pkcs11.c +++ b/lib/pkcs11.c @@ -196,7 +196,7 @@ pkcs11_add_module (const char *name, struct ck_function_list *module) if (memcmp(&info, &providers[i].info, sizeof(info)) == 0) { _gnutls_debug_log("%s is already loaded.\n", name); - return 0; + return GNUTLS_E_INT_RET_0; } } @@ -281,6 +281,7 @@ gnutls_pkcs11_add_provider (const char *name, const char *params) } else { + if (ret == GNUTLS_E_INT_RET_0) ret = 0; p11_kit_finalize_module (module); gnutls_assert (); } @@ -504,7 +505,7 @@ initialize_automatic_p11_kit (void) { name = p11_kit_registered_module_to_name (modules[i]); ret = pkcs11_add_module (name, modules[i]); - if (ret != 0) + if (ret != 0 && ret != GNUTLS_E_INT_RET_0) { gnutls_assert (); _gnutls_debug_log ("Cannot add registered module: %s\n", name);