From 4d600bda7083ebaeb71d94b0fb6df3a760268d45 Mon Sep 17 00:00:00 2001 From: Mateusz Kocielski Date: Tue, 14 Feb 2012 14:14:30 +0000 Subject: [PATCH] * fixed bug #60704 unlink() bug with some files path Reviewed by: rasmus@ --- main/streams/plain_wrapper.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 383004e6f9..80c22ce506 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -1001,9 +1001,12 @@ static php_stream *php_plain_files_stream_opener(php_stream_wrapper *wrapper, ch static int php_plain_files_url_stater(php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) { + char *p; - if (strncmp(url, "file://", sizeof("file://") - 1) == 0) { - url += sizeof("file://") - 1; + if ((p = strstr(url, "://")) != NULL) { + if (p < strchr(url, '/')) { + url = p + 3; + } } if (php_check_open_basedir_ex(url, (flags & PHP_STREAM_URL_STAT_QUIET) ? 0 : 1 TSRMLS_CC)) { @@ -1032,7 +1035,9 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, int op int ret; if ((p = strstr(url, "://")) != NULL) { - url = p + 3; + if (p < strchr(url, '/')) { + url = p + 3; + } } if (php_check_open_basedir(url TSRMLS_CC)) { @@ -1074,11 +1079,15 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c #endif if ((p = strstr(url_from, "://")) != NULL) { - url_from = p + 3; + if (p < strchr(url_from, '/')) { + url_from = p + 3; + } } if ((p = strstr(url_to, "://")) != NULL) { - url_to = p + 3; + if (p < strchr(url_to, '/')) { + url_to = p + 3; + } } if (php_check_open_basedir(url_from TSRMLS_CC) || php_check_open_basedir(url_to TSRMLS_CC)) { @@ -1144,7 +1153,9 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod char *p; if ((p = strstr(dir, "://")) != NULL) { - dir = p + 3; + if (p < strchr(dir, '/')) { + dir = p + 3; + } } if (!recursive) { @@ -1273,7 +1284,9 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, char *url, int #endif if ((p = strstr(url, "://")) != NULL) { - url = p + 3; + if (p < strchr(url, '/')) { + url = p + 3; + } } if (php_check_open_basedir(url TSRMLS_CC)) { -- 2.40.0