summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrelyea%netscape.com <devnull@localhost>2002-05-10 18:13:44 +0000
committerrelyea%netscape.com <devnull@localhost>2002-05-10 18:13:44 +0000
commitc9fdad16cc4fa142631a479a98dd4357932964b9 (patch)
treeefeb9918feb87c8c775ac464285f40397a69709b
parenta8406e709723294641083a3ddc3a5a3d88cd97f0 (diff)
downloadnss-hg-c9fdad16cc4fa142631a479a98dd4357932964b9.tar.gz
Detect when we have a previously deleted internal module which has not yet been freed, and don't try to switch to it.
-rw-r--r--security/nss/lib/pk11wrap/pk11util.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/security/nss/lib/pk11wrap/pk11util.c b/security/nss/lib/pk11wrap/pk11util.c
index b821af7f5..42692eff0 100644
--- a/security/nss/lib/pk11wrap/pk11util.c
+++ b/security/nss/lib/pk11wrap/pk11util.c
@@ -39,6 +39,7 @@
#include "secmodi.h"
#include "pk11func.h"
#include "pki3hack.h"
+#include "secerr.h"
/* these are for displaying error messages */
@@ -47,6 +48,7 @@ static SECMODModuleList *modulesDB = NULL;
static SECMODModuleList *modulesUnload = NULL;
static SECMODModule *internalModule = NULL;
static SECMODModule *defaultDBModule = NULL;
+static SECMODModule *pendingModule = NULL;
static SECMODListLock *moduleLock = NULL;
int secmod_PrivateModuleCount = 0;
@@ -303,6 +305,11 @@ SECMOD_DeleteInternalModule(char *name) {
SECMODModuleList **mlpp;
SECStatus rv = SECFailure;
+ if (pendingModule) {
+ PORT_SetError(SEC_ERROR_MODULE_STUCK);
+ return rv;
+ }
+
SECMOD_GetWriteLock(moduleLock);
for(mlpp = &modules,mlp = modules;
mlp != NULL; mlpp = &mlp->next, mlp = *mlpp) {
@@ -347,7 +354,7 @@ SECMOD_DeleteInternalModule(char *name) {
}
newModule->libraryParams =
PORT_ArenaStrdup(newModule->arena,mlp->module->libraryParams);
- oldModule = internalModule;
+ pendingModule = oldModule = internalModule;
internalModule = NULL;
SECMOD_DestroyModule(oldModule);
SECMOD_DeletePermDB(mlp->module);
@@ -452,6 +459,10 @@ SECStatus SECMOD_AddNewModuleEx(char* moduleName, char* dllPath,
module = SECMOD_CreateModule(dllPath,moduleName, modparms, nssparms);
+ if (module == NULL) {
+ return result;
+ }
+
if (module->dllName != NULL) {
if (module->dllName[0] != 0) {
result = SECMOD_AddModule(module);
@@ -652,6 +663,11 @@ SECMOD_SlotDestroyModule(SECMODModule *module, PRBool fromSlot) {
PK11_USE_THREADS(PZ_Unlock((PZLock *)module->refLock);)
if (!willfree) return;
}
+
+ if (module == pendingModule) {
+ pendingModule = NULL;
+ }
+
if (module->loaded) {
SECMOD_UnloadModule(module);
}