]> granicus.if.org Git - php/commitdiff
* fixed bug #60704 unlink() bug with some files path
authorMateusz Kocielski <shm@php.net>
Tue, 14 Feb 2012 14:14:30 +0000 (14:14 +0000)
committerMateusz Kocielski <shm@php.net>
Tue, 14 Feb 2012 14:14:30 +0000 (14:14 +0000)
Reviewed by: rasmus@

main/streams/plain_wrapper.c

index 383004e6f93d5840b3cb14e8807904a425d1e98e..80c22ce506e24f2b18cb6336eea03723dffe25d9 100644 (file)
@@ -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)) {