Don't dereference a NULL secmodprefix argument. Coverity Bug 336981. NSS_3_11_BRANCH
authornelson%bolyard.com
Thu, 18 May 2006 19:47:37 +0000
branchNSS_3_11_BRANCH
changeset 7096 9d3ab93d346f00a97870de1245ef72cacd9ef73e
parent 7094 942b8d4f4efb5e5276782f7c2937f14c416d70c1
child 7097 c10138cdb4f7c072a20c07b0fba77141956e81e0
push idunknown
push userunknown
push dateunknown
bugs336981
Don't dereference a NULL secmodprefix argument. Coverity Bug 336981. r=alexei.volkov
security/nss/lib/nss/nssinit.c
--- a/security/nss/lib/nss/nssinit.c
+++ b/security/nss/lib/nss/nssinit.c
@@ -296,37 +296,38 @@ static const char *dllname =
 	"NSS Builtin Root Certs";
 #else
 	#error "Uh! Oh! I don't know about this platform."
 #endif
 
 /* Should we have platform ifdefs here??? */
 #define FILE_SEP '/'
 
-static void nss_FindExternalRootPaths(const char *dbpath, const char* secmodprefix,
+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);
+    secmod_len = secmodprefix ? PORT_Strlen(secmodprefix) : 0;
     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) {
+    if (secmod_len > 0) {
         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;
             }