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

From: Date: Sat, 01 Nov 2014 18:51:25 +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-83397@lists.php.net to get a copy of this message
Commit: 3442851f6286b4e9710cdab170cfbc79e2da72f6 Author: mcq8 <php@mcq8.be> Sat, 1 Nov 2014 19:49:21 +0100 Parents: de4638d3fdae935c0d25343e77b8d809f156391c Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3442851f6286b4e9710cdab170cfbc79e2da72f6 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 ed50d8c..e3daf06 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,11 +1258,8 @@ 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) { - 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 @@ -1307,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; @@ -1325,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)) {

« previous php.cvs (#83397) next »