diff options
author | Stanislav Malyshev <stas@php.net> | 2014-11-30 17:35:11 -0800 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2014-11-30 17:35:11 -0800 |
commit | b564e7b0de3457c58d3c69faf5b2b0b29b4f1169 (patch) | |
tree | 47a1d5d2a16162d36611bc8104608e5321adf93c /main/streams/plain_wrapper.c | |
parent | fff70770dd1999d62423f1dbba52fa98a45f01ea (diff) | |
parent | aae5d4d9db27a11f9118546fa16c57132704b889 (diff) | |
download | php-git-b564e7b0de3457c58d3c69faf5b2b0b29b4f1169.tar.gz |
Merge branch 'PHP-5.6'
* PHP-5.6:
Update NEWS
fix typo
Added test and review suggestion
Fix bug #68335: rmdir doesnt work with file:// stream wrapper
Diffstat (limited to 'main/streams/plain_wrapper.c')
-rw-r--r-- | main/streams/plain_wrapper.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 8590647818..40099a1700 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -1036,12 +1036,8 @@ static php_stream *php_plain_files_stream_opener(php_stream_wrapper *wrapper, co static int php_plain_files_url_stater(php_stream_wrapper *wrapper, const char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) { - char *p; - - if ((p = strstr(url, "://")) != NULL) { - if (p < strchr(url, '/')) { - url = p + 3; - } + if (strncasecmp(url, "file://", sizeof("file://") - 1) == 0) { + url += sizeof("file://") - 1; } if (php_check_open_basedir_ex(url, (flags & PHP_STREAM_URL_STAT_QUIET) ? 0 : 1 TSRMLS_CC)) { @@ -1066,13 +1062,10 @@ static int php_plain_files_url_stater(php_stream_wrapper *wrapper, const char *u static int php_plain_files_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) { - char *p; int ret; - if ((p = strstr(url, "://")) != NULL) { - if (p < strchr(url, '/')) { - url = p + 3; - } + if (strncasecmp(url, "file://", sizeof("file://") - 1) == 0) { + url += sizeof("file://") - 1; } if (php_check_open_basedir(url TSRMLS_CC)) { @@ -1095,7 +1088,6 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, const char *url, static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context TSRMLS_DC) { - char *p; int ret; if (!url_from || !url_to) { @@ -1113,16 +1105,12 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f } #endif - if ((p = strstr(url_from, "://")) != NULL) { - if (p < strchr(url_from, '/')) { - url_from = p + 3; - } + if (strncasecmp(url_from, "file://", sizeof("file://") - 1) == 0) { + url_from += sizeof("file://") - 1; } - if ((p = strstr(url_to, "://")) != NULL) { - if (p < strchr(url_to, '/')) { - url_to = p + 3; - } + if (strncasecmp(url_to, "file://", sizeof("file://") - 1) == 0) { + url_to += sizeof("file://") - 1; } if (php_check_open_basedir(url_from TSRMLS_CC) || php_check_open_basedir(url_to TSRMLS_CC)) { @@ -1187,10 +1175,8 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i int ret, recursive = options & PHP_STREAM_MKDIR_RECURSIVE; char *p; - if ((p = strstr(dir, "://")) != NULL) { - if (p < strchr(dir, '/')) { - dir = p + 3; - } + if (strncasecmp(dir, "file://", sizeof("file://") - 1) == 0) { + dir += sizeof("file://") - 1; } if (!recursive) { @@ -1272,6 +1258,10 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) { + if (strncasecmp(url, "file://", sizeof("file://") - 1) == 0) { + url += sizeof("file://") - 1; + } + #if PHP_WIN32 int url_len = (int)strlen(url); #endif @@ -1300,7 +1290,6 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, i static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url, int option, void *value, php_stream_context *context TSRMLS_DC) { struct utimbuf *newtime; - char *p; #if !defined(WINDOWS) && !defined(NETWARE) uid_t uid; gid_t gid; @@ -1318,10 +1307,8 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url } #endif - if ((p = strstr(url, "://")) != NULL) { - if (p < strchr(url, '/')) { - url = p + 3; - } + if (strncasecmp(url, "file://", sizeof("file://") - 1) == 0) { + url += sizeof("file://") - 1; } if (php_check_open_basedir(url TSRMLS_CC)) { |