]> granicus.if.org Git - php/commitdiff
MFH: fix #35999 (recursive mkdir() does not work with relative path like "foo/bar")
authorAntony Dovgal <tony2001@php.net>
Mon, 16 Jan 2006 19:48:23 +0000 (19:48 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 16 Jan 2006 19:48:23 +0000 (19:48 +0000)
NEWS
main/streams/plain_wrapper.c

diff --git a/NEWS b/NEWS
index 78b216729b57c11a0f8d575a0cd6aa2f40546948..7e5559e107734da344eadba02e20ed46c6c44a5e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ PHP                                                                        NEWS
 - Fixed bug #36011 (Strict errormsg wrong for call_user_func() and the likes).
   (Marcus)
 - Fixed bug #36006 (Problem with $this in __destruct()). (Dmitry)
+- Fixed bug #35999 (recursive mkdir() does not work with relative path 
+  like "foo/bar"). (Tony)
 - Fixed bug #35998 (SplFileInfo::getPathname() returns unix style filenames
   in win32). (Marcus)
 
index c61bcc4862b51d020ba53cf637af58006cc08990..f05283fe3b3d3a00aa42cef54fb004c983fdb417 100644 (file)
@@ -1095,12 +1095,17 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod
                        offset = p - buf + 1;
                }
 
-               /* find a top level directory we need to create */
-               while ((p = strrchr(buf + offset, DEFAULT_SLASH))) {
-                       *p = '\0';
-                       if (VCWD_STAT(buf, &sb) == 0) {
-                               *p = DEFAULT_SLASH;
-                               break;
+               if (p && dir_len == 1) {
+                       /* buf == "DEFAULT_SLASH" */    
+               }
+               else {
+                       /* find a top level directory we need to create */
+                       while ( (p = strrchr(buf + offset, DEFAULT_SLASH)) || (p = strrchr(buf, DEFAULT_SLASH)) ) {
+                               *p = '\0';
+                               if (VCWD_STAT(buf, &sb) == 0) {
+                                       *p = DEFAULT_SLASH;
+                                       break;
+                               }
                        }
                }