com php-src: Added test and review suggestion: ext/standard/tests/file/bug68335.phpt main/streams/plain_wrap per.c

From: Date: Mon, 01 Dec 2014 00:38:20 +0000
Subject: com php-src: Added test and review suggestion: ext/standard/tests/file/bug68335.phpt main/streams/plain_wrap per.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-83401@lists.php.net to get a copy of this message
Commit: 04808aa7e18ad0b2f6d014d06777b519e41dbccf Author: mcq8 <php@mcq8.be> Sat, 1 Nov 2014 19:49:21 +0100 Committer: Stanislav Malyshev <stas@php.net> Sun, 30 Nov 2014 16:38:20 -0800 Parents: 6eaa4d01d35e44374e8d7ba930fc25f7abbb434f Branches: PHP-5.5 PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=04808aa7e18ad0b2f6d014d06777b519e41dbccf Log: Added test and review suggestion Changed paths: A ext/standard/tests/file/bug68335.phpt M main/streams/plain_wrapper.c Diff: diff --git a/ext/standard/tests/file/bug68335.phpt b/ext/standard/tests/file/bug68335.phpt new file mode 100644 index 0000000..63eda4d --- /dev/null +++ b/ext/standard/tests/file/bug68335.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #68335: rmdir doesnt work with file:// stream wrapper +--FILE-- +<?php +$dir = 'file://' . dirname(__FILE__) . '/testDir'; +mkdir($dir); +var_dump(is_dir($dir)); +rmdir($dir); +var_dump(is_dir($dir)); +?> +--EXPECT-- +bool(true) +bool(false) diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index bba22b1..aae2f6d 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -1031,12 +1031,8 @@ 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 ((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)) { @@ -1061,13 +1057,10 @@ static int php_plain_files_url_stater(php_stream_wrapper *wrapper, char *url, in static int php_plain_files_unlink(php_stream_wrapper *wrapper, 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)) { @@ -1090,7 +1083,6 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, int op static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC) { - char *p; int ret; if (!url_from || !url_to) { @@ -1108,16 +1100,12 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c } #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)) { @@ -1182,10 +1170,8 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod 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) { @@ -1267,11 +1253,8 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod static int php_plain_files_rmdir(php_stream_wrapper *wrapper, char *url, int options, 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_WIN32 @@ -1302,7 +1285,6 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, char *url, int opt static int php_plain_files_metadata(php_stream_wrapper *wrapper, 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; @@ -1320,10 +1302,8 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, char *url, int } #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)) {

« previous php.cvs (#83401) next »