php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch themostevilpatchever.patch for Filesystem function related Bug #60704

Patch version 2012-02-11 08:32 UTC

Return to Bug #60704 | Download this patch
Patch Revisions:

Developer: shm@php.net

Index: main/streams/plain_wrapper.c
===================================================================
--- main/streams/plain_wrapper.c	(wersja 323157)
+++ main/streams/plain_wrapper.c	(kopia robocza)
@@ -1001,9 +1001,8 @@
 
 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)
 {
-
-	if (strncmp(url, "file://", sizeof("file://") - 1) == 0) {
-		url += sizeof("file://") - 1;
+	if (strncmp(url, "file://", 7) == 0) {
+		url += 7;
 	}
 
 	if (php_check_open_basedir_ex(url, (flags & PHP_STREAM_URL_STAT_QUIET) ? 0 : 1 TSRMLS_CC)) {
@@ -1028,11 +1027,10 @@
 
 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) {
-		url = p + 3;
+	if (strncmp(url, "file://", 7) == 0) {
+		url += 7;
 	}
 
 	if (php_check_open_basedir(url TSRMLS_CC)) {
@@ -1073,12 +1071,12 @@
 	}
 #endif
 
-	if ((p = strstr(url_from, "://")) != NULL) {
-		url_from = p + 3;
+	if (strncmp(url_from, "file://", 7) == 0) {
+		url_from += 7;
 	}
 
-	if ((p = strstr(url_to, "://")) != NULL) {
-		url_to = p + 3;
+	if (strncmp(url_to, "file://", 7) == 0) {
+		url_to += 7;
 	}
 
 	if (php_check_open_basedir(url_from TSRMLS_CC) || php_check_open_basedir(url_to TSRMLS_CC)) {
@@ -1143,8 +1141,8 @@
 	int ret, recursive = options & PHP_STREAM_MKDIR_RECURSIVE;
 	char *p;
 
-	if ((p = strstr(dir, "://")) != NULL) {
-		dir = p + 3;
+	if (strncmp(dir, "file://", 7) == 0) {
+		dir += 7;
 	}
 
 	if (!recursive) {
@@ -1226,15 +1224,12 @@
 
 static int php_plain_files_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC)
 {
-#if PHP_WIN32
-	int url_len = strlen(url);
-#endif
 	if (php_check_open_basedir(url TSRMLS_CC)) {
 		return 0;
 	}
 
 #if PHP_WIN32
-	if (!php_win32_check_trailing_space(url, url_len)) {
+	if (!php_win32_check_trailing_space(url, strlen(url_len))) {
 		php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(ENOENT));
 		return 0;
 	}
@@ -1254,26 +1249,22 @@
 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;
 #endif
 	mode_t mode;
 	int ret = 0;
-#if PHP_WIN32
-	int url_len = strlen(url);
-#endif
 
 #if PHP_WIN32
-	if (!php_win32_check_trailing_space(url, url_len)) {
+	if (!php_win32_check_trailing_space(url, strlen(url_len))) {
 		php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(ENOENT));
 		return 0;
 	}
 #endif
 
-	if ((p = strstr(url, "://")) != NULL) {
-		url = p + 3;
+	if (strncmp(url, "file://", 7) == 0) {
+		url += 7;
 	}
 
 	if (php_check_open_basedir(url TSRMLS_CC)) {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 00:01:27 2024 UTC