Bug 392722 - nsinstall doesn't work if paths have double slashes, patch by Fabien Tassin <fta+bugzilla@sofaraway.org>, r=me
authorbenjamin@smedbergs.us
Wed, 29 Aug 2007 13:05:52 -0700
changeset 5439 cbcaadce11a8b4b60bd6fc68f8dc8304203b19cb
parent 5438 2b5320fe0879f5c4a9f206a8ba767e4a8a07318e
child 5440 e8cd3a3f1da3364c46aec522a87b24a78536b674
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs392722
milestone1.9a8pre
Bug 392722 - nsinstall doesn't work if paths have double slashes, patch by Fabien Tassin <fta+bugzilla@sofaraway.org>, r=me
config/nsinstall.c
--- a/config/nsinstall.c
+++ b/config/nsinstall.c
@@ -106,18 +106,17 @@ mkdirs(char *path, mode_t mode)
 
     /* strip trailing "/." */
     l = strlen(path);
     if(l > 1 && path[l - 1] == '.' && path[l - 2] == '/')
         path[l - 2] = 0;
 
     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 ((lstat(path, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&
 	    mkdirs(path, mode) < 0) {
 	    return -1;
 	}
 	*cp = '/';
     }