Bug 392722 - nsinstall chokes on double slashes in path
authornelson%bolyard.com
Sat, 01 Sep 2007 03:33:56 +0000
changeset 8031 c55e62a8739091c0deb4260a8a72dca5cd4d61da
parent 8030 56d6ea3d34e8903a3f2a9bb487a4fe413db0e119
child 8034 3075d4504837a1478b889103da5bfdd577f93bb1
push idunknown
push userunknown
push dateunknown
bugs392722
Bug 392722 - nsinstall chokes on double slashes in path patch by benjamin@smedbergs.us r=nelson
security/coreconf/nsinstall/nsinstall.c
--- a/security/coreconf/nsinstall/nsinstall.c
+++ b/security/coreconf/nsinstall/nsinstall.c
@@ -120,18 +120,17 @@ mkdirs(char *path, mode_t mode)
     char *      cp;
     int         rv;
     struct stat sb;
     
     if (!path || !path[0]) 
 	fail("Null pointer or empty string passed to mkdirs()");
     while (*path == '/' && path[1] == '/')
 	path++;
-    while ((cp = strrchr(path, '/')) && cp[1] == '\0')
-	*cp = '\0';
+    for (cp = strrchr(path, '/'); cp && cp != path && *(cp - 1) == '/'; cp--);
     if (cp && cp != path) {
 	*cp = '\0';
 	if ((stat(path, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&
 	    mkdirs(path, mode) < 0) {
 	    return -1;
 	}
 	*cp = '/';
     }