summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
Diffstat (limited to 'sapi')
-rw-r--r--sapi/cgi/cgi_main.c2
-rw-r--r--sapi/cli/php_http_parser.h6
-rw-r--r--sapi/cli/tests/php_cli_server.inc6
-rw-r--r--sapi/cli/tests/upload_2G.phpt99
4 files changed, 105 insertions, 8 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 4c78fcafec..221b002175 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -508,7 +508,7 @@ static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
uint read_bytes = 0;
int tmp_read_bytes;
- count_bytes = MIN(count_bytes, (uint) SG(request_info).content_length - SG(read_post_bytes));
+ count_bytes = MIN(count_bytes, SG(request_info).content_length - SG(read_post_bytes));
while (read_bytes < count_bytes) {
tmp_read_bytes = read(STDIN_FILENO, buffer + read_bytes, count_bytes - read_bytes);
if (tmp_read_bytes <= 0) {
diff --git a/sapi/cli/php_http_parser.h b/sapi/cli/php_http_parser.h
index 2bf2356725..31502e213a 100644
--- a/sapi/cli/php_http_parser.h
+++ b/sapi/cli/php_http_parser.h
@@ -29,15 +29,13 @@ extern "C" {
#include <sys/types.h>
#if defined(_WIN32) && !defined(__MINGW32__)
# include <windows.h>
-# include "win32/php_stdint.h"
# include "config.w32.h"
#else
# include "php_config.h"
-# ifdef HAVE_STDINT_H
-# include <stdint.h>
-# endif
#endif
+#include "php_stdint.h"
+
/* Compile with -DPHP_HTTP_PARSER_STRICT=0 to make less checks, but run
* faster
*/
diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc
index 40c5361995..77a79e0f04 100644
--- a/sapi/cli/tests/php_cli_server.inc
+++ b/sapi/cli/tests/php_cli_server.inc
@@ -3,7 +3,7 @@ define ("PHP_CLI_SERVER_HOSTNAME", "localhost");
define ("PHP_CLI_SERVER_PORT", 8964);
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) {
+function php_cli_server_start($code = 'echo "Hello world";', $no_router = FALSE, $cmd_args = null) {
$php_executable = getenv('TEST_PHP_EXECUTABLE');
$doc_root = __DIR__;
$router = "index.php";
@@ -19,14 +19,14 @@ function php_cli_server_start($code = 'echo "Hello world";', $no_router = FALSE)
);
if (substr(PHP_OS, 0, 3) == 'WIN') {
- $cmd = "{$php_executable} -t {$doc_root} -n -S " . PHP_CLI_SERVER_ADDRESS;
+ $cmd = "{$php_executable} -t {$doc_root} -n {$cmd_args} -S " . PHP_CLI_SERVER_ADDRESS;
if (!$no_router) {
$cmd .= " {$router}";
}
$handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true));
} else {
- $cmd = "exec {$php_executable} -t {$doc_root} -n -S " . PHP_CLI_SERVER_ADDRESS;
+ $cmd = "exec {$php_executable} -t {$doc_root} -n {$cmd_args} -S " . PHP_CLI_SERVER_ADDRESS;
if (!$no_router) {
$cmd .= " {$router}";
}
diff --git a/sapi/cli/tests/upload_2G.phpt b/sapi/cli/tests/upload_2G.phpt
new file mode 100644
index 0000000000..fe13d90007
--- /dev/null
+++ b/sapi/cli/tests/upload_2G.phpt
@@ -0,0 +1,99 @@
+--TEST--
+file upload greater than 2G
+--SKIPIF--
+<?php
+include "skipif.inc";
+
+if (PHP_INT_SIZE < 8) {
+ die("skip need PHP_INT_SIZE>=8");
+}
+
+if ($f = fopen("/proc/meminfo","r")) {
+ while (!feof($f)) {
+ if (!strncmp($line = fgets($f), "MemFree", 7)) {
+ if (substr($line,8)/1024/1024 > 3) {
+ $enough_free_ram = true;
+ }
+ }
+ }
+}
+
+if (empty($enough_free_ram)) {
+ die("need +3G free RAM");
+}
+?>
+--FILE--
+<?php
+
+echo "Test\n";
+
+include "php_cli_server.inc";
+
+php_cli_server_start("var_dump(\$_FILES);", false,
+ "-d post_max_size=3G -d upload_max_filesize=3G");
+
+list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
+$port = intval($port)?:80;
+$length = 2150000000;
+$output = "";
+
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+ die("connect failed");
+}
+
+$prev = "----123
+Content-Type: text/plain
+Content-Disposition: form-data; name=\"file1\"; filename=\"file1.txt\"\n\n";
+$post = "\n----123--\n";
+$total = $length + strlen($prev) + strlen($post);
+
+fwrite($fp, <<<EOF
+POST /index.php HTTP/1.1
+Host: {$host}
+Content-Type: multipart/form-data; boundary=--123
+Content-Length: {$total}
+
+{$prev}
+EOF
+) or die("write prev failed");
+
+$data = str_repeat("0123456789", 10000);
+for ($i = 0; $i < $length; $i += 10000 * 10) {
+ fwrite($fp, $data) or die("write failed @ ($i)");
+}
+
+fwrite($fp, $post) or die("write post failed");
+
+while (!feof($fp)) {
+ $output .= fgets($fp);
+}
+echo $output;
+fclose($fp);
+?>
+Done
+--EXPECTF--
+Test
+
+HTTP/1.1 200 OK
+Host: %s
+Connection: close
+X-Powered-By: PHP/%s
+Content-type: text/html
+
+array(1) {
+ ["file1"]=>
+ array(5) {
+ ["name"]=>
+ string(9) "file1.txt"
+ ["type"]=>
+ string(10) "text/plain"
+ ["tmp_name"]=>
+ string(14) "/tmp/php%s"
+ ["error"]=>
+ int(0)
+ ["size"]=>
+ int(2150000000)
+ }
+}
+Done