diff options
author | Pierre Joye <pajoye@php.net> | 2011-07-26 17:44:20 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2011-07-26 17:44:20 +0000 |
commit | fc8afdf178d5672e74e67683e21404bc31f361fc (patch) | |
tree | 09a58587de7dbbee2bd8b96e8620433a4cf54205 /main/streams/plain_wrapper.c | |
parent | 498aaae6d86f9b32c4da160bd50cb5962a0b8617 (diff) | |
download | php-git-fc8afdf178d5672e74e67683e21404bc31f361fc.tar.gz |
- Fixed bug 55124, recursive mkdir fails with current (dot) directory in path
Diffstat (limited to 'main/streams/plain_wrapper.c')
-rw-r--r-- | main/streams/plain_wrapper.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 041a0e34e2..8303adb5b1 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -1147,24 +1147,18 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod ret = php_mkdir(dir, mode TSRMLS_CC); } else { /* we look for directory separator from the end of string, thus hopefuly reducing our work load */ - char *e, *buf; + char *e; struct stat sb; int dir_len = strlen(dir); int offset = 0; + char buf[MAXPATHLEN]; - buf = estrndup(dir, dir_len); - -#ifdef PHP_WIN32 - e = buf; - while (*e) { - if (*e == '/') { - *e = DEFAULT_SLASH; - } - e++; + if (!expand_filepath_with_mode(dir, buf, NULL, 0, CWD_EXPAND TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid path"); + return 0; } -#else - e = buf + dir_len; -#endif + + e = buf + strlen(buf); if ((p = memchr(buf, DEFAULT_SLASH, dir_len))) { offset = p - buf + 1; @@ -1216,7 +1210,6 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod } } } - efree(buf); } if (ret < 0) { /* Failure */ |