Blame SOURCES/php-5.5.21-CVE-2015-4025.patch

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