Index: mozilla/security/nss/lib/nss/nssinit.c =================================================================== RCS file: /cvsroot/mozilla/security/nss/lib/nss/nssinit.c,v retrieving revision 1.72 diff -pU20 -r1.72 mozilla/security/nss/lib/nss/nssinit.c --- mozilla/security/nss/lib/nss/nssinit.c +++ mozilla/security/nss/lib/nss/nssinit.c @@ -304,53 +304,51 @@ static const char *dllname = static void nss_FindExternalRootPaths(const char *dbpath, const char* secmodprefix, char** retoldpath, char** retnewpath) { char *path, *oldpath = NULL, *lastsep; int len, path_len, secmod_len, dll_len; path_len = PORT_Strlen(dbpath); secmod_len = PORT_Strlen(secmodprefix); dll_len = PORT_Strlen(dllname); len = path_len + secmod_len + dll_len + 2; /* FILE_SEP + NULL */ path = PORT_Alloc(len); if (path == NULL) return; /* back up to the top of the directory */ PORT_Memcpy(path,dbpath,path_len); if (path[path_len-1] != FILE_SEP) { path[path_len++] = FILE_SEP; } PORT_Strcpy(&path[path_len],dllname); - if (secmodprefix) { - lastsep = PORT_Strrchr(secmodprefix, FILE_SEP); - if (lastsep) { - int secmoddir_len = lastsep-secmodprefix+1; /* FILE_SEP */ - oldpath = PORT_Alloc(len); - if (oldpath == NULL) { - PORT_Free(path); - return; - } - PORT_Memcpy(oldpath,path,path_len); - PORT_Memcpy(&oldpath[path_len],secmodprefix,secmoddir_len); - PORT_Strcpy(&oldpath[path_len+secmoddir_len],dllname); + lastsep = PORT_Strrchr(secmodprefix, FILE_SEP); + if (lastsep) { + int secmoddir_len = lastsep-secmodprefix+1; /* FILE_SEP */ + oldpath = PORT_Alloc(len); + if (oldpath == NULL) { + PORT_Free(path); + return; } + PORT_Memcpy(oldpath,path,path_len); + PORT_Memcpy(&oldpath[path_len],secmodprefix,secmoddir_len); + PORT_Strcpy(&oldpath[path_len+secmoddir_len],dllname); } *retoldpath = oldpath; *retnewpath = path; return; } static void nss_FreeExternalRootPaths(char* oldpath, char* path) { if (path) { PORT_Free(path); } if (oldpath) { PORT_Free(oldpath); } } static void nss_FindExternalRoot(const char *dbpath, const char* secmodprefix) { char *path = NULL; @@ -562,40 +560,42 @@ NSS_InitReadWrite(const char *configdir) * ensure continuous operation and proper shutdown * sequence if another piece of code is using the same * PKCS#11 modules that NSS is accessing without going * through NSS, for example Java SunPKCS11 provider. * The following limitation applies when this is set : * SECMOD_WaitForAnyTokenEvent will not use * C_WaitForSlotEvent, in order to prevent the need for * C_Finalize. This call will be emulated instead. * NSS_INIT_RESERVED - Currently has no effect, but may be used in the * future to trigger better cooperation between PKCS#11 * modules used by both NSS and the Java SunPKCS11 * provider. This should occur after a new flag is defined * for C_Initialize by the PKCS#11 working group. * NSS_INIT_COOPERATE - Sets 4 recommended options for applications that * use both NSS and the Java SunPKCS11 provider. */ SECStatus NSS_Initialize(const char *configdir, const char *certPrefix, const char *keyPrefix, const char *secmodName, PRUint32 flags) { + if (!secmodName) + return SECFailure; return nss_Init(configdir, certPrefix, keyPrefix, secmodName, ((flags & NSS_INIT_READONLY) == NSS_INIT_READONLY), ((flags & NSS_INIT_NOCERTDB) == NSS_INIT_NOCERTDB), ((flags & NSS_INIT_NOMODDB) == NSS_INIT_NOMODDB), ((flags & NSS_INIT_FORCEOPEN) == NSS_INIT_FORCEOPEN), ((flags & NSS_INIT_NOROOTINIT) == NSS_INIT_NOROOTINIT), ((flags & NSS_INIT_OPTIMIZESPACE) == NSS_INIT_OPTIMIZESPACE), ((flags & NSS_INIT_PK11THREADSAFE) == NSS_INIT_PK11THREADSAFE), ((flags & NSS_INIT_PK11RELOAD) == NSS_INIT_PK11RELOAD), ((flags & NSS_INIT_NOPK11FINALIZE) == NSS_INIT_NOPK11FINALIZE)); } /* * initialize NSS without a creating cert db's, key db's, or secmod db's. */ SECStatus NSS_NoDB_Init(const char * configdir) { return nss_Init("","","","", PR_TRUE,PR_TRUE,PR_TRUE,PR_TRUE,PR_TRUE,PR_TRUE,