diff options
author | nelsonb%netscape.com <devnull@localhost> | 2003-10-11 01:49:24 +0000 |
---|---|---|
committer | nelsonb%netscape.com <devnull@localhost> | 2003-10-11 01:49:24 +0000 |
commit | 03ab12595ac456d04abcd5a80d6e6b88bc4d17d0 (patch) | |
tree | 52b5b855cc9255e04f7d1e854e871d2cd05294ac | |
parent | e6edc3a585e5cb6db4ffb6217e8dadaae4e9c95c (diff) | |
download | nss-hg-03ab12595ac456d04abcd5a80d6e6b88bc4d17d0.tar.gz |
Correctly handle a NULL moduleSpecList. Bug 220217.
-rw-r--r-- | security/nss/lib/pk11wrap/pk11pars.c | 35 | ||||
-rw-r--r-- | security/nss/lib/softoken/pk11db.c | 16 |
2 files changed, 34 insertions, 17 deletions
diff --git a/security/nss/lib/pk11wrap/pk11pars.c b/security/nss/lib/pk11wrap/pk11pars.c index 2ec1d4573..bdbe87f33 100644 --- a/security/nss/lib/pk11wrap/pk11pars.c +++ b/security/nss/lib/pk11wrap/pk11pars.c @@ -41,6 +41,7 @@ #include "secmod.h" #include "secmodi.h" #include "pki3hack.h" +#include "secerr.h" #include "pk11pars.h" @@ -319,23 +320,33 @@ SECMOD_LoadModule(char *modulespec,SECMODModule *parent, PRBool recurse) if (recurse && module->isModuleDB) { char ** moduleSpecList; - char **index; + PORT_SetError(0); moduleSpecList = SECMOD_GetModuleSpecList(module); - - for (index = moduleSpecList; index && *index; index++) { - SECMODModule *child; - child = SECMOD_LoadModule(*index,module,PR_TRUE); - if (!child) break; - if (child->isCritical && !child->loaded) { - rv = SECFailure; + if (moduleSpecList) { + char **index; + + for (index = moduleSpecList; *index; index++) { + SECMODModule *child; + child = SECMOD_LoadModule(*index,module,PR_TRUE); + if (!child) break; + if (child->isCritical && !child->loaded) { + int err = PORT_GetError(); + if (!err) + err = SEC_ERROR_NO_MODULE; + SECMOD_DestroyModule(child); + PORT_SetError(err); + rv = SECFailure; + break; + } SECMOD_DestroyModule(child); - break; } - SECMOD_DestroyModule(child); + SECMOD_FreeModuleSpecList(module,moduleSpecList); + } else { + if (!PORT_GetError()) + PORT_SetError(SEC_ERROR_NO_MODULE); + rv = SECFailure; } - - SECMOD_FreeModuleSpecList(module,moduleSpecList); } if (rv != SECSuccess) { diff --git a/security/nss/lib/softoken/pk11db.c b/security/nss/lib/softoken/pk11db.c index 5a4906984..220e897ba 100644 --- a/security/nss/lib/softoken/pk11db.c +++ b/security/nss/lib/softoken/pk11db.c @@ -796,9 +796,13 @@ done: if (pkcs11db) { secmod_CloseDB(pkcs11db); - } else { + } else if (moduleList[0] && rw) { secmod_AddPermDB(appName,filename,dbname,moduleList[0], rw) ; } + if (!moduleList[0]) { + PORT_Free(moduleList); + moduleList = NULL; + } return moduleList; } @@ -806,11 +810,13 @@ SECStatus secmod_ReleasePermDBData(const char *appName, const char *filename, const char *dbname, char **moduleSpecList, PRBool rw) { - char **index; - for(index = moduleSpecList; *index; index++) { - PR_smprintf_free(*index); + if (moduleSpecList) { + char **index; + for(index = moduleSpecList; *index; index++) { + PR_smprintf_free(*index); + } + PORT_Free(moduleSpecList); } - PORT_Free(moduleSpecList); return SECSuccess; } |