From 3062348c75963e14a4030faedd08f81bdd0120f7 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Mon, 16 Jan 2006 19:48:23 +0000 Subject: [PATCH] MFH: fix #35999 (recursive mkdir() does not work with relative path like "foo/bar") --- NEWS | 2 ++ main/streams/plain_wrapper.c | 17 +++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 78b216729b..7e5559e107 100644 --- 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) diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index c61bcc4862..f05283fe3b 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -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; + } } } -- 2.50.1