diff options
author | Antony Dovgal <tony2001@php.net> | 2006-01-16 19:47:07 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2006-01-16 19:47:07 +0000 |
commit | 07ff99a0759db3247f8b2fbae7616210a50acf86 (patch) | |
tree | c95cf0d63ff81e1dc2c0bf6a6142f413053c814e | |
parent | 9e7ddd51ee108b436146c812c7a516ba0f6c46c0 (diff) | |
download | php-git-07ff99a0759db3247f8b2fbae7616210a50acf86.tar.gz |
fix bug #35999 (recursive mkdir() does not work with relative path like "foo/bar")
-rw-r--r-- | main/streams/plain_wrapper.c | 17 |
1 files changed, 11 insertions, 6 deletions
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; + } } } |