]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-5.5' into PHP-5.6
authorStanislav Malyshev <stas@php.net>
Mon, 1 Dec 2014 01:07:02 +0000 (17:07 -0800)
committerStanislav Malyshev <stas@php.net>
Mon, 1 Dec 2014 01:07:02 +0000 (17:07 -0800)
* PHP-5.5:
  Added test and review suggestion
  Fix bug #68335: rmdir doesnt work with file:// stream wrapper

1  2 
main/streams/plain_wrapper.c

index 69c6a3ce266586de170b1305868a0102c788a834,aae2f6da369d0c62c39b226aebe94bdbd6a7433f..6d8b5c203def3b4bd5caea6a0221b115b3e68bee
@@@ -1023,14 -1029,10 +1023,10 @@@ static php_stream *php_plain_files_stre
        return php_stream_fopen_rel(path, mode, opened_path, options);
  }
  
 -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)
 +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)) {
                return VCWD_STAT(url, &ssb->sb);
  }
  
 -static int php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC)
 +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)) {
        return 1;
  }
  
 -static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC)
 +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) {
@@@ -1259,8 -1251,12 +1245,12 @@@ static int php_plain_files_mkdir(php_st
        }
  }
  
 -static int php_plain_files_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC)
 +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 = strlen(url);
  #endif
        return 1;
  }
  
 -static int php_plain_files_metadata(php_stream_wrapper *wrapper, char *url, int option, void *value, php_stream_context *context TSRMLS_DC)
 +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;