Browse Source
Merge branch '2Guploads'
Merge branch '2Guploads'
* 2Guploads: add NEWS entry; add simple test more precise condition make this work in vc11 too Use int64_t and atoll() after discussion with johannes ws Patch for https://bugs.php.net/bug.php?id=44522 to allow uploading files above 2G. unify stdint type usagepull/403/head
29 changed files with 356 additions and 280 deletions
-
2Makefile.global
-
19acinclude.m4
-
3configure.in
-
1ext/date/config0.m4
-
10ext/date/lib/timelib_structs.h
-
10ext/exif/exif.c
-
2ext/hash/config.m4
-
3ext/hash/config.w32
-
1ext/hash/package.xml
-
7ext/hash/php_hash.h
-
71ext/hash/php_hash_types.h
-
12ext/mysqlnd/config9.m4
-
107ext/mysqlnd/mysqlnd_portability.h
-
9ext/oci8/oci8.c
-
3ext/phar/phar_internal.h
-
5ext/spl/php_spl.h
-
17ext/standard/crypt_freesec.h
-
6ext/standard/crypt_sha256.c
-
6ext/standard/crypt_sha512.c
-
7ext/standard/string.c
-
6ext/zip/lib/zipconf.h
-
5main/SAPI.h
-
2main/php.h
-
198main/php_stdint.h
-
11main/rfc1867.c
-
2sapi/cgi/cgi_main.c
-
6sapi/cli/php_http_parser.h
-
6sapi/cli/tests/php_cli_server.inc
-
99sapi/cli/tests/upload_2G.phpt
@ -1,71 +0,0 @@ |
|||
/* |
|||
+----------------------------------------------------------------------+ |
|||
| PHP Version 5 | |
|||
+----------------------------------------------------------------------+ |
|||
| Copyright (c) 1997-2013 The PHP Group | |
|||
+----------------------------------------------------------------------+ |
|||
| This source file is subject to version 3.01 of the PHP license, | |
|||
| that is bundled with this package in the file LICENSE, and is | |
|||
| available through the world-wide-web at the following url: | |
|||
| http://www.php.net/license/3_01.txt | |
|||
| If you did not receive a copy of the PHP license and are unable to | |
|||
| obtain it through the world-wide-web, please send a note to | |
|||
| license@php.net so we can mail you a copy immediately. | |
|||
+----------------------------------------------------------------------+ |
|||
| Author: Michael Wallner <mike@php.net> | |
|||
+----------------------------------------------------------------------+ |
|||
*/ |
|||
|
|||
/* $Id$ */ |
|||
|
|||
#ifndef PHP_HASH_TYPES_H |
|||
#define PHP_HASH_TYPES_H |
|||
|
|||
#ifdef HAVE_CONFIG_H |
|||
#include "config.h" |
|||
#else |
|||
#ifndef PHP_WIN32 |
|||
#include "php_config.h" |
|||
#endif |
|||
#endif |
|||
|
|||
#ifndef PHP_WIN32 |
|||
#if SIZEOF_LONG == 8 |
|||
#define L64(x) x |
|||
typedef unsigned long php_hash_uint64; |
|||
#if SIZEOF_INT == 4 |
|||
typedef unsigned int php_hash_uint32; |
|||
#elif SIZEOF_SHORT == 4 |
|||
typedef unsigned short php_hash_uint32; |
|||
#else |
|||
#error "Need a 32bit integer type" |
|||
#endif |
|||
#elif SIZEOF_LONG_LONG == 8 |
|||
#define L64(x) x##LL |
|||
typedef unsigned long long php_hash_uint64; |
|||
#if SIZEOF_INT == 4 |
|||
typedef unsigned int php_hash_uint32; |
|||
#elif SIZEOF_LONG == 4 |
|||
typedef unsigned long php_hash_uint32; |
|||
#else |
|||
#error "Need a 32bit integer type" |
|||
#endif |
|||
#else |
|||
#error "Need a 64bit integer type" |
|||
#endif |
|||
#else |
|||
#define L64(x) x##i64 |
|||
typedef unsigned __int64 php_hash_uint64; |
|||
typedef unsigned __int32 php_hash_uint32; |
|||
#endif |
|||
|
|||
#endif |
|||
|
|||
/* |
|||
* Local variables: |
|||
* tab-width: 4 |
|||
* c-basic-offset: 4 |
|||
* End: |
|||
* vim600: sw=4 ts=4 fdm=marker |
|||
* vim<600: sw=4 ts=4 |
|||
*/ |
|||
@ -0,0 +1,198 @@ |
|||
/* |
|||
+----------------------------------------------------------------------+ |
|||
| PHP Version 5 | |
|||
+----------------------------------------------------------------------+ |
|||
| Copyright (c) 1997-2013 The PHP Group | |
|||
+----------------------------------------------------------------------+ |
|||
| This source file is subject to version 3.01 of the PHP license, | |
|||
| that is bundled with this package in the file LICENSE, and is | |
|||
| available through the world-wide-web at the following url: | |
|||
| http://www.php.net/license/3_01.txt | |
|||
| If you did not receive a copy of the PHP license and are unable to | |
|||
| obtain it through the world-wide-web, please send a note to | |
|||
| license@php.net so we can mail you a copy immediately. | |
|||
+----------------------------------------------------------------------+ |
|||
| Author: Michael Wallner <mike@php.net> | |
|||
+----------------------------------------------------------------------+ |
|||
*/ |
|||
|
|||
#ifndef PHP_STDINT_H |
|||
#define PHP_STDINT_H |
|||
|
|||
#if PHP_WIN32 |
|||
# include "win32/php_stdint.h" |
|||
# define HAVE_INT8_T 1 |
|||
# define HAVE_UINT8_T 1 |
|||
# define HAVE_INT16_T 1 |
|||
# define HAVE_UINT16_T 1 |
|||
# define HAVE_INT32_T 1 |
|||
# define HAVE_UINT32_T 1 |
|||
# define HAVE_INT64_T 1 |
|||
# define HAVE_UINT64_T 1 |
|||
#else |
|||
|
|||
#include "php_config.h" |
|||
|
|||
#if HAVE_SYS_TYPES_H |
|||
# include <sys/types.h> |
|||
#endif |
|||
|
|||
#if HAVE_INTTYPES_H |
|||
# include <inttypes.h> |
|||
#endif |
|||
|
|||
#if HAVE_STDINT_H |
|||
# include <stdint.h> |
|||
#endif |
|||
|
|||
#ifndef HAVE_INT8_T |
|||
# ifdef HAVE_INT8 |
|||
typedef int8 int8_t; |
|||
# else |
|||
typedef signed char int8_t; |
|||
# endif |
|||
#endif |
|||
|
|||
#ifndef INT8_C |
|||
# define INT8_C(c) c |
|||
#endif |
|||
|
|||
#ifndef HAVE_UINT8_T |
|||
# ifdef HAVE_UINT8 |
|||
typedef uint8 uint8_t |
|||
# elif HAVE_U_INT8_T |
|||
typedef u_int8_t uint8_t; |
|||
# else |
|||
typedef unsigned char uint8_t; |
|||
# endif |
|||
#endif |
|||
|
|||
#ifndef UINT8_C |
|||
# define UINT8_C(c) c |
|||
#endif |
|||
|
|||
#ifndef HAVE_INT16_T |
|||
# ifdef HAVE_INT16 |
|||
typedef int16 int16_t; |
|||
# elif SIZEOF_SHORT >= 2 |
|||
typedef signed short int16_t; |
|||
# else |
|||
# error "No suitable 16bit integer type found" |
|||
# endif |
|||
#endif |
|||
|
|||
#ifndef INT16_C |
|||
# define INT16_C(c) c |
|||
#endif |
|||
|
|||
#ifndef HAVE_UINT16_T |
|||
# ifdef HAVE_UINT16 |
|||
typedef uint16 uint16_t |
|||
# elif HAVE_U_INT16_T |
|||
typedef u_int16_t uint16_t; |
|||
# elif SIZEOF_SHORT >= 2 |
|||
typedef unsigned short uint16_t; |
|||
# else |
|||
# error "No suitable 16bit integer type found" |
|||
# endif |
|||
#endif |
|||
|
|||
#ifndef UINT16_C |
|||
# define UINT16_C(c) c |
|||
#endif |
|||
|
|||
#ifndef HAVE_INT32_T |
|||
# ifdef HAVE_INT32 |
|||
typedef int32 int32_t; |
|||
# elif SIZEOF_INT >= 4 |
|||
typedef int int32_t; |
|||
# elif SIZEOF_LONG >= 4 |
|||
typedef long int32_t; |
|||
# else |
|||
# error "No suitable 32bit integer type found" |
|||
# endif |
|||
#endif |
|||
|
|||
#ifndef INT32_C |
|||
# define INT32_C(c) c |
|||
#endif |
|||
|
|||
#ifndef HAVE_UINT32_T |
|||
# ifdef HAVE_UINT32 |
|||
typedef uint32 uint32_t |
|||
# elif HAVE_U_INT32_T |
|||
typedef u_int32_t uint32_t; |
|||
# elif SIZEOF_INT >= 4 |
|||
typedef unsigned int uint32_t; |
|||
# elif SIZEOF_LONG >= 4 |
|||
typedef unsigned long uint32_t; |
|||
# else |
|||
# error "No suitable 32bit integer type found" |
|||
# endif |
|||
#endif |
|||
|
|||
#ifndef UINT32_C |
|||
# define UINT32_C(c) c ## U |
|||
#endif |
|||
|
|||
#ifndef HAVE_INT64_T |
|||
# ifdef HAVE_INT64 |
|||
typedef int64 int64_t; |
|||
# elif SIZEOF_INT >= 8 |
|||
typedef int int64_t; |
|||
# elif SIZEOF_LONG >= 8 |
|||
typedef long int64_t; |
|||
# elif SIZEOF_LONG_LONG >= 8 |
|||
typedef long long int64_t; |
|||
# else |
|||
# error "No suitable 64bit integer type found" |
|||
# endif |
|||
#endif |
|||
|
|||
#ifndef INT64_C |
|||
# if SIZEOF_INT >= 8 |
|||
# define INT64_C(c) c |
|||
# elif SIZEOF_LONG >= 8 |
|||
# define INT64_C(c) c ## L |
|||
# elif SIZEOF_LONG_LONG >= 8 |
|||
# define INT64_C(c) c ## LL |
|||
# endif |
|||
#endif |
|||
|
|||
#ifndef HAVE_UINT64_T |
|||
# ifdef HAVE_UINT64 |
|||
typedef uint64 uint64_t |
|||
# elif HAVE_U_INT64_T |
|||
typedef u_int64_t uint64_t; |
|||
# elif SIZEOF_INT >= 8 |
|||
typedef unsigned int uint64_t; |
|||
# elif SIZEOF_LONG >= 8 |
|||
typedef unsigned long uint64_t; |
|||
# elif SIZEOF_LONG_LONG >= 8 |
|||
typedef unsigned long long uint64_t; |
|||
# else |
|||
# error "No suitable 64bit integer type found" |
|||
# endif |
|||
#endif |
|||
|
|||
#ifndef UINT64_C |
|||
# if SIZEOF_INT >= 8 |
|||
# define UINT64_C(c) c ## U |
|||
# elif SIZEOF_LONG >= 8 |
|||
# define UINT64_C(c) c ## UL |
|||
# elif SIZEOF_LONG_LONG >= 8 |
|||
# define UINT64_C(c) c ## ULL |
|||
# endif |
|||
#endif |
|||
|
|||
#endif /* !PHP_WIN32 */ |
|||
#endif /* PHP_STDINT_H */ |
|||
|
|||
/* |
|||
* Local variables: |
|||
* tab-width: 4 |
|||
* c-basic-offset: 4 |
|||
* End: |
|||
* vim600: sw=4 ts=4 fdm=marker |
|||
* vim<600: sw=4 ts=4 |
|||
*/ |
|||
@ -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 |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue