b74969
Adapted for 5.4.16 from
b74969
b74969
From be9b2a95adb504abd5acdc092d770444ad6f6854 Mon Sep 17 00:00:00 2001
b74969
From: Stanislav Malyshev <stas@php.net>
b74969
Date: Sat, 9 May 2015 23:13:06 -0700
b74969
Subject: [PATCH] Fixed bug #69418 - more s->p fixes for filenames
b74969
b74969
---
b74969
 ext/pcntl/pcntl.c              | 74 +++++++++++++++++++++---------------------
b74969
 ext/standard/basic_functions.c | 24 +++++++-------
b74969
 ext/standard/dir.c             | 62 +++++++++++++++++------------------
b74969
 ext/standard/file.c            | 10 +++---
b74969
 4 files changed, 85 insertions(+), 85 deletions(-)
b74969
b74969
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
b74969
index 7a8acaf..6189bdf 100644
b74969
--- a/ext/pcntl/pcntl.c
b74969
+++ b/ext/pcntl/pcntl.c
b74969
@@ -754,19 +754,19 @@ PHP_FUNCTION(pcntl_exec)
b74969
 	char *path;
b74969
 	int path_len;
b74969
 	ulong key_num;
b74969
-		
b74969
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|aa", &path, &path_len, &args, &envs) == FAILURE) {
b74969
+
b74969
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|aa", &path, &path_len, &args, &envs) == FAILURE) {
b74969
 		return;
b74969
 	}
b74969
-	
b74969
+
b74969
 	if (ZEND_NUM_ARGS() > 1) {
b74969
 		/* Build argument list */
b74969
 		args_hash = HASH_OF(args);
b74969
 		argc = zend_hash_num_elements(args_hash);
b74969
-		
b74969
+
b74969
 		argv = safe_emalloc((argc + 2), sizeof(char *), 0);
b74969
 		*argv = path;
b74969
-		for ( zend_hash_internal_pointer_reset(args_hash), current_arg = argv+1; 
b74969
+		for ( zend_hash_internal_pointer_reset(args_hash), current_arg = argv+1;
b74969
 			(argi < argc && (zend_hash_get_current_data(args_hash, (void **) &element) == SUCCESS));
b74969
 			(argi++, current_arg++, zend_hash_move_forward(args_hash)) ) {
b74969
 
b74969
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
b74969
index c3e2230..7d0bfed 100644
b74969
--- a/ext/standard/basic_functions.c
b74969
+++ b/ext/standard/basic_functions.c
b74969
@@ -5433,7 +5433,7 @@ PHP_FUNCTION(set_include_path)
b74969
 	int new_value_len;
b74969
 	char *old_value;
b74969
 
b74969
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &new_value, &new_value_len) == FAILURE) {
b74969
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &new_value, &new_value_len) == FAILURE) {
b74969
 		return;
b74969
 	}
b74969
 
b74969
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
b74969
index c64f37c..27ffb9d 100644
b74969
--- a/ext/standard/dir.c
b74969
+++ b/ext/standard/dir.c
b74969
@@ -219,12 +219,12 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject)
b74969
 	php_stream_context *context = NULL;
b74969
 	php_stream *dirp;
b74969
 
b74969
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|r", &dirname, &dir_len, &zcontext) == FAILURE) {
b74969
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|r", &dirname, &dir_len, &zcontext) == FAILURE) {
b74969
 		RETURN_NULL();
b74969
 	}
b74969
 
b74969
 	context = php_stream_context_from_zval(zcontext, 0);
b74969
-	
b74969
+
b74969
 	dirp = php_stream_opendir(dirname, REPORT_ERRORS, context);
b74969
 
b74969
 	if (dirp == NULL) {
b74969
@@ -293,11 +293,11 @@ PHP_FUNCTION(chroot)
b74969
 {
b74969
 	char *str;
b74969
 	int ret, str_len;
b74969
-	
b74969
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
b74969
+
b74969
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &str, &str_len) == FAILURE) {
b74969
 		RETURN_FALSE;
b74969
 	}
b74969
-	
b74969
+
b74969
 	ret = chroot(str);
b74969
 	if (ret != 0) {
b74969
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s (errno %d)", strerror(errno), errno);
b74969
diff --git a/ext/standard/file.c b/ext/standard/file.c
b74969
index 708c3e2..21e1e53 100644
b74969
--- a/ext/standard/file.c
b74969
+++ b/ext/standard/file.c
b74969
@@ -805,7 +805,7 @@ PHP_FUNCTION(tempnam)
b74969
 	char *p;
b74969
 	int fd;
b74969
 
b74969
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ps", &dir, &dir_len, &prefix, &prefix_len) == FAILURE) {
b74969
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pp", &dir, &dir_len, &prefix, &prefix_len) == FAILURE) {
b74969
 		return;
b74969
 	}
b74969
 
b74969
@@ -1332,7 +1332,7 @@ PHP_FUNCTION(rmdir)
b74969
 	zval *zcontext = NULL;
b74969
 	php_stream_context *context;
b74969
 
b74969
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|r", &dir, &dir_len, &zcontext) == FAILURE) {
b74969
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|r", &dir, &dir_len, &zcontext) == FAILURE) {
b74969
 		RETURN_FALSE;
b74969
 	}
b74969
 
b74969
-- 
b74969
2.1.4
b74969
b74969
From 634aa0a2dbf8ec5e6fabb4ee01c6d1355ba7ee67 Mon Sep 17 00:00:00 2001
b74969
From: Stanislav Malyshev <stas@php.net>
b74969
Date: Sun, 10 May 2015 23:33:44 -0700
b74969
Subject: [PATCH] Update tests
b74969
b74969
---
b74969
 ext/standard/tests/dir/dir_variation1.phpt         | 22 +++++++++++-----------
b74969
 .../tests/dir/opendir_variation1-win32.phpt        | 12 ++++++------
b74969
 ext/standard/tests/dir/opendir_variation1.phpt     | 12 ++++++------
b74969
 .../tests/file/mkdir_rmdir_variation2.phpt         |  2 +-
b74969
 .../tests/file/tempnam_variation3-win32.phpt       | 18 +++++++++---------
b74969
 ext/standard/tests/file/tempnam_variation3.phpt    | 22 ++++++++++++----------
b74969
 .../tests/general_functions/include_path.phpt      |  4 ++--
b74969
 7 files changed, 47 insertions(+), 45 deletions(-)
b74969
b74969
diff --git a/ext/standard/tests/dir/dir_variation1.phpt b/ext/standard/tests/dir/dir_variation1.phpt
b74969
index abb4719..fff04ba 100644
b74969
--- a/ext/standard/tests/dir/dir_variation1.phpt
b74969
+++ b/ext/standard/tests/dir/dir_variation1.phpt
b74969
@@ -8,7 +8,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
b74969
 ?>
b74969
 --FILE--
b74969
 
b74969
-/* 
b74969
+/*
b74969
  * Prototype  : object dir(string $directory[, resource $context])
b74969
  * Description: Directory class with properties, handle and class and methods read, rewind and close
b74969
  * Source code: ext/standard/dir.c
b74969
@@ -34,7 +34,7 @@ class A
b74969
 }
b74969
 
b74969
 // get a resource variable
b74969
-$fp = fopen(__FILE__, "r"); // get a file handle 
b74969
+$fp = fopen(__FILE__, "r"); // get a file handle
b74969
 $dfp = opendir( dirname(__FILE__) ); // get a dir handle
b74969
 
b74969
 // unexpected values to be passed to $directory argument
b74969
@@ -92,27 +92,27 @@ echo "Done";
b74969
 
b74969
 -- Iteration 1 --
b74969
 
b74969
-Warning: dir() expects parameter 1 to be string, array given in %s on line %d
b74969
+Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
b74969
 NULL
b74969
 
b74969
 -- Iteration 2 --
b74969
 
b74969
-Warning: dir() expects parameter 1 to be string, array given in %s on line %d
b74969
+Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
b74969
 NULL
b74969
 
b74969
 -- Iteration 3 --
b74969
 
b74969
-Warning: dir() expects parameter 1 to be string, array given in %s on line %d
b74969
+Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
b74969
 NULL
b74969
 
b74969
 -- Iteration 4 --
b74969
 
b74969
-Warning: dir() expects parameter 1 to be string, array given in %s on line %d
b74969
+Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
b74969
 NULL
b74969
 
b74969
 -- Iteration 5 --
b74969
 
b74969
-Warning: dir() expects parameter 1 to be string, array given in %s on line %d
b74969
+Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
b74969
 NULL
b74969
 
b74969
 -- Iteration 6 --
b74969
@@ -151,16 +151,16 @@ bool(false)
b74969
 
b74969
 -- Iteration 16 --
b74969
 
b74969
-Warning: dir() expects parameter 1 to be string, resource given in %s on line %d
b74969
+Warning: dir() expects parameter 1 to be a valid path, resource given in %s on line %d
b74969
 NULL
b74969
 
b74969
 -- Iteration 17 --
b74969
 
b74969
-Warning: dir() expects parameter 1 to be string, resource given in %s on line %d
b74969
+Warning: dir() expects parameter 1 to be a valid path, resource given in %s on line %d
b74969
 NULL
b74969
 
b74969
 -- Iteration 18 --
b74969
 
b74969
-Warning: dir() expects parameter 1 to be string, object given in %s on line %d
b74969
+Warning: dir() expects parameter 1 to be a valid path, object given in %s on line %d
b74969
 NULL
b74969
-Done
b74969
\ No newline at end of file
b74969
+Done
b74969
diff --git a/ext/standard/tests/dir/opendir_variation1-win32.phpt b/ext/standard/tests/dir/opendir_variation1-win32.phpt
b74969
index 9a75a5b..9bf3c4a 100644
b74969
--- a/ext/standard/tests/dir/opendir_variation1-win32.phpt
b74969
+++ b/ext/standard/tests/dir/opendir_variation1-win32.phpt
b74969
@@ -9,7 +9,7 @@ if (substr(PHP_OS, 0, 3) != 'WIN') {
b74969
 --FILE--
b74969
 
b74969
 /* Prototype  : mixed opendir(string $path[, resource $context])
b74969
- * Description: Open a directory and return a dir_handle 
b74969
+ * Description: Open a directory and return a dir_handle
b74969
  * Source code: ext/standard/dir.c
b74969
  */
b74969
 
b74969
@@ -30,7 +30,7 @@ unset ($unset_var);
b74969
 
b74969
 // get a class
b74969
 class classA {
b74969
-	
b74969
+
b74969
 	var $path;
b74969
 	function __construct($path) {
b74969
 		$this->path = $path;
b74969
@@ -73,7 +73,7 @@ $inputs = array(
b74969
        false,
b74969
        TRUE,
b74969
        FALSE,
b74969
-       
b74969
+
b74969
        // empty data
b74969
 /*16*/ "",
b74969
        '',
b74969
@@ -83,7 +83,7 @@ $inputs = array(
b74969
 /*19*/ "$path",
b74969
        'string',
b74969
        $heredoc,
b74969
-       
b74969
+
b74969
        // object data
b74969
 /*22*/ new classA($path),
b74969
 
b74969
@@ -216,7 +216,7 @@ bool(false)
b74969
 
b74969
 -- Iteration 18 --
b74969
 
b74969
-Warning: opendir() expects parameter 1 to be string, array given in %s on line %d
b74969
+Warning: opendir() expects parameter 1 to be a valid path, array given in %s on line %d
b74969
 NULL
b74969
 
b74969
 -- Iteration 19 --
b74969
@@ -243,6 +243,6 @@ bool(false)
b74969
 
b74969
 -- Iteration 25 --
b74969
 
b74969
-Warning: opendir() expects parameter 1 to be string, resource given in %s on line %d
b74969
+Warning: opendir() expects parameter 1 to be a valid path, resource given in %s on line %d
b74969
 NULL
b74969
 ===DONE===
b74969
diff --git a/ext/standard/tests/dir/opendir_variation1.phpt b/ext/standard/tests/dir/opendir_variation1.phpt
b74969
index 8d195e1..cb4d543 100644
b74969
--- a/ext/standard/tests/dir/opendir_variation1.phpt
b74969
+++ b/ext/standard/tests/dir/opendir_variation1.phpt
b74969
@@ -9,7 +9,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
b74969
 --FILE--
b74969
 
b74969
 /* Prototype  : mixed opendir(string $path[, resource $context])
b74969
- * Description: Open a directory and return a dir_handle 
b74969
+ * Description: Open a directory and return a dir_handle
b74969
  * Source code: ext/standard/dir.c
b74969
  */
b74969
 
b74969
@@ -30,7 +30,7 @@ unset ($unset_var);
b74969
 
b74969
 // get a class
b74969
 class classA {
b74969
-	
b74969
+
b74969
 	var $path;
b74969
 	function __construct($path) {
b74969
 		$this->path = $path;
b74969
@@ -73,7 +73,7 @@ $inputs = array(
b74969
        false,
b74969
        TRUE,
b74969
        FALSE,
b74969
-       
b74969
+
b74969
        // empty data
b74969
 /*16*/ "",
b74969
        '',
b74969
@@ -83,7 +83,7 @@ $inputs = array(
b74969
 /*19*/ "$path",
b74969
        'string',
b74969
        $heredoc,
b74969
-       
b74969
+
b74969
        // object data
b74969
 /*22*/ new classA($path),
b74969
 
b74969
@@ -194,7 +194,7 @@ bool(false)
b74969
 
b74969
 -- Iteration 18 --
b74969
 
b74969
-Warning: opendir() expects parameter 1 to be string, array given in %s on line %d
b74969
+Warning: opendir() expects parameter 1 to be a valid path, array given in %s on line %d
b74969
 NULL
b74969
 
b74969
 -- Iteration 19 --
b74969
@@ -219,6 +219,6 @@ bool(false)
b74969
 
b74969
 -- Iteration 25 --
b74969
 
b74969
-Warning: opendir() expects parameter 1 to be string, resource given in %s on line %d
b74969
+Warning: opendir() expects parameter 1 to be a valid path, resource given in %s on line %d
b74969
 NULL
b74969
 ===DONE===
b74969
diff --git a/ext/standard/tests/file/mkdir_rmdir_variation2.phpt b/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
b74969
index 14dd361..24dfc96 100644
b74969
--- a/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
b74969
+++ b/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
b74969
@@ -68,7 +68,7 @@ bool(false)
b74969
 Warning: mkdir() expects parameter 1 to be a valid path, string given in %s on line %d
b74969
 bool(false)
b74969
 
b74969
-Warning: rmdir(%s): No such file or directory in %s on line %d
b74969
+Warning: rmdir() expects parameter 1 to be a valid path, string given in %s on line %d
b74969
 bool(false)
b74969
 
b74969
 *** Testing mkdir() with miscelleneous input ***
b74969
diff --git a/ext/standard/tests/file/tempnam_variation3-win32.phpt b/ext/standard/tests/file/tempnam_variation3-win32.phpt
b74969
index fb457cb..cc8194a 100644
b74969
--- a/ext/standard/tests/file/tempnam_variation3-win32.phpt
b74969
+++ b/ext/standard/tests/file/tempnam_variation3-win32.phpt
b74969
@@ -22,9 +22,9 @@ if (!mkdir($file_path)) {
b74969
 
b74969
 $file_path = realpath($file_path);
b74969
 
b74969
-/* An array of prefixes */ 
b74969
+/* An array of prefixes */
b74969
 $names_arr = array(
b74969
-	/* Valid args (casting)*/ 
b74969
+	/* Valid args (casting)*/
b74969
 	-1,
b74969
 	TRUE,
b74969
 	FALSE,
b74969
@@ -32,17 +32,17 @@ $names_arr = array(
b74969
 	"",
b74969
 	" ",
b74969
 	"\0",
b74969
-	/* Invalid args */ 
b74969
+	/* Invalid args */
b74969
 	array(),
b74969
 
b74969
-	/* Valid args*/ 
b74969
+	/* Valid args*/
b74969
 	/* prefix with path separator of a non existing directory*/
b74969
-	"/no/such/file/dir", 
b74969
+	"/no/such/file/dir",
b74969
 	"php/php"
b74969
 );
b74969
 
b74969
 $res_arr = array(
b74969
-	/* Invalid args */ 
b74969
+	/* Invalid args */
b74969
 	true,
b74969
 	true,
b74969
 	true,
b74969
@@ -53,7 +53,7 @@ $res_arr = array(
b74969
 	false,
b74969
 
b74969
 	/* prefix with path separator of a non existing directory*/
b74969
-	true, 
b74969
+	true,
b74969
 	true
b74969
 );
b74969
 
b74969
@@ -72,7 +72,7 @@ for( $i=0; $i
b74969
 		} else {
b74969
 			echo "Failed, not created in the correct directory " . realpath($file_dir) . ' vs ' . $file_path ."\n";
b74969
 		}
b74969
-		
b74969
+
b74969
 		if (!is_writable($file_name)) {
b74969
 			printf("%o\n", fileperms($file_name) );
b74969
 
b74969
@@ -105,7 +105,7 @@ Failed, not created in the correct directory %s vs %s
b74969
 OK
b74969
 -- Iteration 7 --
b74969
 
b74969
-Warning: tempnam() expects parameter 2 to be string, array given in %s\ext\standard\tests\file\tempnam_variation3-win32.php on line %d
b74969
+Warning: tempnam() expects parameter 2 to be a valid path, array given in %s\ext\standard\tests\file\tempnam_variation3-win32.php on line %d
b74969
 OK
b74969
 -- Iteration 8 --
b74969
 OK
b74969
diff --git a/ext/standard/tests/file/tempnam_variation3.phpt b/ext/standard/tests/file/tempnam_variation3.phpt
b74969
index 69ab16c..11b8780 100644
b74969
--- a/ext/standard/tests/file/tempnam_variation3.phpt
b74969
+++ b/ext/standard/tests/file/tempnam_variation3.phpt
b74969
@@ -17,9 +17,9 @@ echo "*** Testing tempnam() with obscure prefixes ***\n";
b74969
 $file_path = dirname(__FILE__)."/tempnamVar3";
b74969
 mkdir($file_path);
b74969
 
b74969
-/* An array of prefixes */ 
b74969
+/* An array of prefixes */
b74969
 $names_arr = array(
b74969
-  /* Invalid args */ 
b74969
+  /* Invalid args */
b74969
   -1,
b74969
   TRUE,
b74969
   FALSE,
b74969
@@ -30,7 +30,7 @@ $names_arr = array(
b74969
   array(),
b74969
 
b74969
   /* prefix with path separator of a non existing directory*/
b74969
-  "/no/such/file/dir", 
b74969
+  "/no/such/file/dir",
b74969
   "php/php"
b74969
 
b74969
 );
b74969
@@ -48,10 +48,10 @@ for( $i=0; $i
b74969
     echo "File permissions are => ";
b74969
     printf("%o", fileperms($file_name) );
b74969
     echo "\n";
b74969
-    
b74969
+
b74969
     echo "File created in => ";
b74969
     $file_dir = dirname($file_name);
b74969
-        
b74969
+
b74969
     if ($file_dir == sys_get_temp_dir()) {
b74969
        echo "temp dir\n";
b74969
     }
b74969
@@ -61,7 +61,7 @@ for( $i=0; $i
b74969
     else {
b74969
        echo "unknown location\n";
b74969
     }
b74969
-    
b74969
+
b74969
   }
b74969
   else {
b74969
     echo "-- File is not created --\n";
b74969
@@ -100,12 +100,14 @@ File name is => %s/%s
b74969
 File permissions are => 100600
b74969
 File created in => directory specified
b74969
 -- Iteration 6 --
b74969
-File name is => %s/%s
b74969
-File permissions are => 100600
b74969
-File created in => directory specified
b74969
+
b74969
+Warning: tempnam() expects parameter 2 to be a valid path, string given in %s on line %d
b74969
+-- File is not created --
b74969
+
b74969
+Warning: unlink(): %s in %s on line %d
b74969
 -- Iteration 7 --
b74969
 
b74969
-Warning: tempnam() expects parameter 2 to be string, array given in %s on line %d
b74969
+Warning: tempnam() expects parameter 2 to be a valid path, array given in %s on line %d
b74969
 -- File is not created --
b74969
 
b74969
 Warning: unlink(): %s in %s on line %d
b74969
diff --git a/ext/standard/tests/general_functions/include_path.phpt b/ext/standard/tests/general_functions/include_path.phpt
b74969
index 0392307..8b6626f 100644
b74969
--- a/ext/standard/tests/general_functions/include_path.phpt
b74969
+++ b/ext/standard/tests/general_functions/include_path.phpt
b74969
@@ -41,7 +41,7 @@ var_dump(get_include_path());
b74969
 
b74969
 echo "Done\n";
b74969
 ?>
b74969
---EXPECTF--	
b74969
+--EXPECTF--
b74969
 string(1) "."
b74969
 
b74969
 Warning: get_include_path() expects exactly 0 parameters, 1 given in %s on line %d
b74969
@@ -67,7 +67,7 @@ string(1) "."
b74969
 NULL
b74969
 string(1) "."
b74969
 
b74969
-Warning: set_include_path() expects parameter 1 to be string, array given in %s on line %d
b74969
+Warning: set_include_path() expects parameter 1 to be a valid path, array given in %s on line %d
b74969
 NULL
b74969
 string(1) "."
b74969
 NULL
b74969
-- 
b74969
2.1.4
b74969