Correctly handle a NULL moduleSpecList. Bug 220217.

git-svn-id: svn://10.0.0.236/trunk@147867 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
nelsonb%netscape.com
2003-10-11 01:49:24 +00:00
parent 458f866ce8
commit bcedd95a62
2 changed files with 33 additions and 16 deletions

View File

@@ -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);
if (moduleSpecList) {
char **index;
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;
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) {

View File

@@ -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;
}