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