Merge branch 'PHP-5.5' into PHP-5.6

* PHP-5.5:
  Handle NULL strings in sapi_cli_server_register_variable().
  Allow CLI server test scripts to specify the name of the router file.

Conflicts:
	sapi/cli/tests/php_cli_server.inc
This commit is contained in:
Adam Harvey 2015-01-06 01:27:37 +00:00
commit 27ff425b78
9 changed files with 51 additions and 10 deletions

3
NEWS
View File

@ -22,6 +22,9 @@
- CGI: - CGI:
. Fix bug #68618 (out of bounds read crashes php-cgi). (Stas) . Fix bug #68618 (out of bounds read crashes php-cgi). (Stas)
- CLI server:
. Fix bug #68745 (Invalid HTTP requests make web server segfault). (Adam)
- cURL: - cURL:
. Fixed bug #67643 (curl_multi_getcontent returns '' when . Fixed bug #67643 (curl_multi_getcontent returns '' when
CURLOPT_RETURNTRANSFER isn't set). (Jille Timmermans) CURLOPT_RETURNTRANSFER isn't set). (Jille Timmermans)

View File

@ -708,6 +708,11 @@ static void sapi_cli_server_register_variable(zval *track_vars_array, const char
{ {
char *new_val = (char *)val; char *new_val = (char *)val;
uint new_val_len; uint new_val_len;
if (NULL == val) {
return;
}
if (sapi_module.input_filter(PARSE_SERVER, (char*)key, &new_val, strlen(val), &new_val_len TSRMLS_CC)) { if (sapi_module.input_filter(PARSE_SERVER, (char*)key, &new_val, strlen(val), &new_val_len TSRMLS_CC)) {
php_register_variable_safe((char *)key, new_val, new_val_len, track_vars_array TSRMLS_CC); php_register_variable_safe((char *)key, new_val, new_val_len, track_vars_array TSRMLS_CC);
} }

View File

@ -7,7 +7,7 @@ include "skipif.inc";
--FILE-- --FILE--
<?php <?php
include "php_cli_server.inc"; include "php_cli_server.inc";
php_cli_server_start('<?php ?>', true); php_cli_server_start('<?php ?>', null);
/* /*
* If a Mime Type is added in php_cli_server.c, add it to this array and update * If a Mime Type is added in php_cli_server.c, add it to this array and update

View File

@ -0,0 +1,34 @@
--TEST--
Bug #68745 (Invalid HTTP requests make web server segfault)
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
include "php_cli_server.inc";
php_cli_server_start('var_dump(count($_SERVER));', 'not-index.php');
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port)?:80;
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
die("connect failed");
}
if(fwrite($fp, "GET www.example.com:80 HTTP/1.1\r\n\r\n")) {
while (!feof($fp)) {
echo fgets($fp);
}
}
fclose($fp);
?>
--EXPECTF--
HTTP/1.1 200 OK
Connection: close
X-Powered-By: %s
Content-type: text/html; charset=UTF-8
int(%d)

View File

@ -3,13 +3,12 @@ define ("PHP_CLI_SERVER_HOSTNAME", "localhost");
define ("PHP_CLI_SERVER_PORT", 8964); define ("PHP_CLI_SERVER_PORT", 8964);
define ("PHP_CLI_SERVER_ADDRESS", PHP_CLI_SERVER_HOSTNAME.":".PHP_CLI_SERVER_PORT); define ("PHP_CLI_SERVER_ADDRESS", PHP_CLI_SERVER_HOSTNAME.":".PHP_CLI_SERVER_PORT);
function php_cli_server_start($code = 'echo "Hello world";', $no_router = FALSE, $cmd_args = null) { function php_cli_server_start($code = 'echo "Hello world";', $router = 'index.php', $cmd_args = null) {
$php_executable = getenv('TEST_PHP_EXECUTABLE'); $php_executable = getenv('TEST_PHP_EXECUTABLE');
$doc_root = __DIR__; $doc_root = __DIR__;
$router = "index.php";
if ($code) { if ($code) {
file_put_contents($doc_root . '/' . $router, '<?php ' . $code . ' ?>'); file_put_contents($doc_root . '/' . ($router ?: 'index.php'), '<?php ' . $code . ' ?>');
} }
$descriptorspec = array( $descriptorspec = array(
@ -20,14 +19,14 @@ function php_cli_server_start($code = 'echo "Hello world";', $no_router = FALSE,
if (substr(PHP_OS, 0, 3) == 'WIN') { if (substr(PHP_OS, 0, 3) == 'WIN') {
$cmd = "{$php_executable} -t {$doc_root} -n {$cmd_args} -S " . PHP_CLI_SERVER_ADDRESS; $cmd = "{$php_executable} -t {$doc_root} -n {$cmd_args} -S " . PHP_CLI_SERVER_ADDRESS;
if (!$no_router) { if (!is_null($router)) {
$cmd .= " {$router}"; $cmd .= " {$router}";
} }
$handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true)); $handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true));
} else { } else {
$cmd = "exec {$php_executable} -t {$doc_root} -n {$cmd_args} -S " . PHP_CLI_SERVER_ADDRESS; $cmd = "exec {$php_executable} -t {$doc_root} -n {$cmd_args} -S " . PHP_CLI_SERVER_ADDRESS;
if (!$no_router) { if (!is_null($router)) {
$cmd .= " {$router}"; $cmd .= " {$router}";
} }
$cmd .= " 2>/dev/null"; $cmd .= " 2>/dev/null";

View File

@ -10,7 +10,7 @@ include "skipif.inc";
--FILE-- --FILE--
<?php <?php
include "php_cli_server.inc"; include "php_cli_server.inc";
php_cli_server_start('var_dump($_SERVER["PATH_INFO"]);', TRUE); php_cli_server_start('var_dump($_SERVER["PATH_INFO"]);', null);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port)?:80; $port = intval($port)?:80;

View File

@ -7,7 +7,7 @@ include "skipif.inc";
--FILE-- --FILE--
<?php <?php
include "php_cli_server.inc"; include "php_cli_server.inc";
php_cli_server_start('var_dump($_SERVER["PHP_SELF"], $_SERVER["SCRIPT_NAME"], $_SERVER["PATH_INFO"], $_SERVER["QUERY_STRING"]);', TRUE); php_cli_server_start('var_dump($_SERVER["PHP_SELF"], $_SERVER["SCRIPT_NAME"], $_SERVER["PATH_INFO"], $_SERVER["QUERY_STRING"]);', null);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port)?:80; $port = intval($port)?:80;

View File

@ -7,7 +7,7 @@ include "skipif.inc";
--FILE-- --FILE--
<?php <?php
include "php_cli_server.inc"; include "php_cli_server.inc";
php_cli_server_start(NULL, TRUE); php_cli_server_start(NULL, NULL);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port)?:80; $port = intval($port)?:80;

View File

@ -7,7 +7,7 @@ include "skipif.inc";
--FILE-- --FILE--
<?php <?php
include "php_cli_server.inc"; include "php_cli_server.inc";
php_cli_server_start('echo done, "\n";', TRUE); php_cli_server_start('echo done, "\n";', null);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port)?:80; $port = intval($port)?:80;