summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2002-05-07 23:35:22 +0000
committerwtc%netscape.com <devnull@localhost>2002-05-07 23:35:22 +0000
commit00a7d7fa4c279ca5be1b7a598cd10a8c0912fd02 (patch)
treeee7515a53a5c00c2c1107235810a74aef07d9144
parentd7794dca672b3fdbe37caf9f8213881be5b99d71 (diff)
downloadnss-hg-00a7d7fa4c279ca5be1b7a598cd10a8c0912fd02.tar.gz
Bugzilla bug 136279: Return oldpath only if it is different from path.
Avoid an unnecessary call to SECMOD_HasRootCerts in nss_FindExternalRoot.
-rw-r--r--security/nss/lib/nss/nssinit.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/security/nss/lib/nss/nssinit.c b/security/nss/lib/nss/nssinit.c
index 627e5efc2..8e265b578 100644
--- a/security/nss/lib/nss/nssinit.c
+++ b/security/nss/lib/nss/nssinit.c
@@ -277,7 +277,7 @@ static const char *dllname =
static void nss_FindExternalRootPaths(const char *dbpath, const char* secmodprefix,
char** retoldpath, char** retnewpath)
{
- char *path, *oldpath, *lastsep;
+ char *path, *oldpath = NULL, *lastsep;
int len, path_len, secmod_len, dll_len;
path_len = PORT_Strlen(dbpath);
@@ -287,28 +287,27 @@ static void nss_FindExternalRootPaths(const char *dbpath, const char* secmodpref
path = PORT_Alloc(len);
if (path == NULL) return;
- oldpath = PORT_Alloc(len);
- if (oldpath == NULL) {
- PORT_Free(path);
- 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_Memcpy(oldpath,path,path_len);
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);
- path_len += secmoddir_len;
+ PORT_Strcpy(&oldpath[path_len+secmoddir_len],dllname);
}
}
- PORT_Strcpy(&oldpath[path_len],dllname);
*retoldpath = oldpath;
*retnewpath = path;
return;
@@ -329,6 +328,7 @@ nss_FindExternalRoot(const char *dbpath, const char* secmodprefix)
{
char *path = NULL;
char *oldpath = NULL;
+ PRBool hasrootcerts = PR_FALSE;
/*
* 'oldpath' is the external root path in NSS 3.3.x or older.
@@ -338,8 +338,9 @@ nss_FindExternalRoot(const char *dbpath, const char* secmodprefix)
nss_FindExternalRootPaths(dbpath, secmodprefix, &oldpath, &path);
if (oldpath) {
(void) SECMOD_AddNewModule("Root Certs",oldpath, 0, 0);
+ hasrootcerts = SECMOD_HasRootCerts();
}
- if (path && !SECMOD_HasRootCerts()) {
+ if (path && !hasrootcerts) {
(void) SECMOD_AddNewModule("Root Certs",path, 0, 0);
}
nss_FreeExternalRootPaths(oldpath, path);