summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2011-12-09 05:37:41 +0000
committerXinchen Hui <laruence@php.net>2011-12-09 05:37:41 +0000
commit147c4142791dc69266afad1f378acc3de9fdb5f1 (patch)
tree88119faeb032c0749d173a4b0d5522ea72a250fc
parent726b31cfc90618587dcfd5bd33b1c4086c83090a (diff)
downloadphp-git-147c4142791dc69266afad1f378acc3de9fdb5f1.tar.gz
Fixed bug #60477 (Segfault after two multipart/form-data POST requests)
-rw-r--r--NEWS3
-rw-r--r--sapi/cli/php_cli_server.c1
-rw-r--r--sapi/cli/tests/php_cli_server_014.phpt76
3 files changed, 80 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index ddd75a02ad..3996013160 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? Dec 2011, PHP 5.4.0 RC4
+- CLI SAPI:
+ . Fixed bug #60477 (Segfault after two multipart/form-data POST requests).
+ (Laruence)
08 Dec 2011, PHP 5.4.0 RC3
- Core:
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index de4f4b65b5..3854486765 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -1921,6 +1921,7 @@ static int php_cli_server_request_shutdown(php_cli_server *server, php_cli_serve
php_cli_server_close_connection(server, client TSRMLS_CC);
destroy_request_info(&SG(request_info));
SG(server_context) = NULL;
+ SG(rfc1867_uploaded_files) = NULL;
return SUCCESS;
}
/* }}} */
diff --git a/sapi/cli/tests/php_cli_server_014.phpt b/sapi/cli/tests/php_cli_server_014.phpt
new file mode 100644
index 0000000000..4e95040b5f
--- /dev/null
+++ b/sapi/cli/tests/php_cli_server_014.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Bug #60477: Segfault after two multipart/form-data POST requestes
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+include "php_cli_server.inc";
+php_cli_server_start('echo done, "\n";', TRUE);
+
+list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
+$port = intval($port)?:80;
+$output = '';
+
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+ die("connect failed");
+}
+
+if(fwrite($fp, <<<HEADER
+POST /index.php HTTP/1.1
+Host: {$host}
+Content-Type: multipart/form-data; boundary=---------123456789
+Content-Length: 70
+
+---------123456789
+Content-Type: application/x-www-form-urlencoded
+a=b
+HEADER
+)) {
+ while (!feof($fp)) {
+ $output .= fgets($fp);
+ }
+}
+
+fclose($fp);
+
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if(fwrite($fp, <<<HEADER
+POST /main/no-exists.php HTTP/1.1
+Host: {$host}
+Content-Type: multipart/form-data; boundary=---------123456789
+Content-Length: 70
+
+---------123456789
+Content-Type: application/x-www-form-urlencoded
+a=b
+HEADER
+)) {
+ while (!feof($fp)) {
+ $output .= fgets($fp);
+ }
+}
+
+echo preg_replace("/<style type=\"text\/css\">(.*?)<\/style>/s", "<style type=\"text/css\">AAA</style>", $output), "\n";
+fclose($fp);
+
+?>
+--EXPECTF--
+
+HTTP/1.1 200 OK
+Host: %s
+Connection: closed
+X-Powered-By: %s
+Content-type: %s
+
+done
+HTTP/1.1 404 Not Found
+Host: %s
+Connection: closed
+Content-Type: %s
+Content-Length: %d
+
+<html><head><title>404 Not Found</title><style type="text/css">AAA</style>
+</head><body><h1 class="h">Not Found</h1><p>The requested resource /main/no-exists.php was not found on this server.</p></body></html>