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

Patch php_copy_file_ctx-destination-check-fix for *General Issues Bug #71630

Patch version 2016-02-19 12:40 UTC

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

Developer: vladimir@volomp.com

diff --git a/ext/standard/file.c b/ext/standard/file.c
index 26f5c16..30c56ce 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -1713,16 +1713,10 @@ PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_flg, php
 		return FAILURE;
 	}
 
-	switch (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET | PHP_STREAM_URL_STAT_NOCACHE, &dest_s, ctx)) {
-		case -1:
-			/* non-statable stream */
-			goto safe_to_copy;
-			break;
-		case 0:
-			break;
-		default: /* failed to stat file, does not exist? */
-			return ret;
-	}
+        if (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET | PHP_STREAM_URL_STAT_NOCACHE, &dest_s, ctx) != 0) {
+                goto safe_to_copy;
+        }
+
 	if (S_ISDIR(dest_s.sb.st_mode)) {
 		php_error_docref(NULL, E_WARNING, "The second argument to copy() function cannot be a directory");
 		return FAILURE;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 19:01:28 2024 UTC