com php-src: Patch for https://bugs.php.net/bug.php?i d=44522 to allow uploading files above 2G.: main/SAPI.h main/rfc1867.c sapi/cg i/cgi_main.c

From: Date: Tue, 06 Aug 2013 20:51:57 +0000
Subject: com php-src: Patch for https://bugs.php.net/bug.php?i d=44522 to allow uploading files above 2G.: main/SAPI.h main/rfc1867.c sapi/cg i/cgi_main.c
Groups: php.cvs 
Request: Send a blank email to [email protected] to get a copy of this message
Commit:    84f9213e00ae624e789ec0ed8f023c22a557d215
Author:    Ralf Lang <[email protected]>         Fri, 28 Jun 2013 08:32:10 +0200
Committer: Michael Wallner <[email protected]>      Tue, 6 Aug 2013 22:51:57 +0200
Parents:   14caf174ff219376e4f1234bd297ffe973cc416e
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=84f9213e00ae624e789ec0ed8f023c22a557d215

Log:
Patch for https://bugs.php.net/bug.php?id=44522
to allow uploading files
above 2G.

This is essentially the same as the patch
"uploads_larger_than_2g_HEAD_v2 (last revision 2012-03-26 03:59 UTC) by
jason at infininull dot com)" but using off_t instead of signed long
(originally: uint)

I tested this on 64bit linux and succeeded uploading a file of 4.8 G.
The File did not get corrupted or truncated in any way.

I did not yet test this under windows or 32 bit linux

Note that there are still limitations:

* Did not test for files > 8 G
* php does not yet reject absurdly high values
* Still limited by underlying file system specific limits and free space
* in upload
* tmp dir and destination dir

Changed paths:
  M  main/SAPI.h
  M  main/rfc1867.c
  M  sapi/cgi/cgi_main.c


Diff:
diff --git a/main/SAPI.h b/main/SAPI.h
index 92b7329..c3cacb5 100644
--- a/main/SAPI..h
+++ b/main/SAPI.h
@@ -82,7 +82,7 @@ typedef struct {
 	char *post_data, *raw_post_data;
 	char *cookie_data;
 	long content_length;
-	uint post_data_length, raw_post_data_length;
+	off_t post_data_length, raw_post_data_length;
 
 	char *path_translated;
 	char *request_uri;
@@ -119,7 +119,7 @@ typedef struct _sapi_globals_struct {
 	void *server_context;
 	sapi_request_info request_info;
 	sapi_headers_struct sapi_headers;
-	int read_post_bytes;
+	off_t read_post_bytes;
 	unsigned char headers_sent;
 	struct stat global_stat;
 	char *default_mimetype;
diff --git a/main/rfc1867.c b/main/rfc1867..c
index ed7ce9c..78a7ad2 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -676,8 +676,9 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
 {
 	char *boundary, *s = NULL, *boundary_end = NULL, *start_arr = NULL, *array_index = NULL;
 	char *temp_filename = NULL, *lbuf = NULL, *abuf = NULL;
-	int boundary_len = 0, total_bytes = 0, cancel_upload = 0, is_arr_upload = 0, array_len = 0;
-	int max_file_size = 0, skip_upload = 0, anonindex = 0, is_anonymous;
+	int boundary_len = 0, cancel_upload = 0, is_arr_upload = 0, array_len = 0;
+       off_t total_bytes = 0, max_file_size = 0;
+	int skip_upload = 0, anonindex = 0, is_anonymous;
 	zval *http_post_files = NULL;
 	HashTable *uploaded_files = NULL;
 	multipart_buffer *mbuff;
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 4c78fca..221b002 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) {



Thread (3 messages)

« previous php.cvs (#72875) next »