com php-src: fix limitation of upload size == (U)INT _MAX in CGI: sapi/cgi/cgi_main.c sapi/fpm/fpm/f pm_main.c
| From: | Michael Wallner | Date: | Mon, 28 Oct 2013 06:37:47 +0000 |
| Subject: | com php-src: fix limitation of upload size == (U)INT _MAX in CGI: sapi/cgi/cgi_main.c sapi/fpm/fpm/f pm_main.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-73800@lists.php.net to get a copy of this message | ||
Commit: 8962f3ff0c76c5710f5e14d6f342f44498ff882b
Author: Michael Wallner <mike@php.net> Fri, 25 Oct 2013 09:42:54 +0200
Parents: d1727d8401238cb816a9b900efaf221a33a8e764
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8962f3ff0c76c5710f5e14d6f342f44498ff882b
Log:
fix limitation of upload size == (U)INT_MAX in CGI
Changed paths:
M sapi/cgi/cgi_main.c
M sapi/fpm/fpm/fpm_main.c
Diff:
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 221b002..43816d4 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -524,8 +524,11 @@ static int sapi_fcgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
uint read_bytes = 0;
int tmp_read_bytes;
fcgi_request *request = (fcgi_request*) SG(server_context);
+ size_t remaining = SG(request_info).content_length - SG(read_post_bytes);
- count_bytes = MIN(count_bytes, (uint) SG(request_info).content_length - SG(read_post_bytes));
+ if (remaining < count_bytes) {
+ count_bytes = remaining;
+ }
while (read_bytes < count_bytes) {
tmp_read_bytes = fcgi_read(request, buffer + read_bytes, count_bytes - read_bytes);
if (tmp_read_bytes <= 0) {
diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c
index 4b20e63..91abfea 100644
--- a/sapi/fpm/fpm/fpm_main.c
+++ b/sapi/fpm/fpm/fpm_main.c
@@ -498,8 +498,11 @@ static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
{
uint read_bytes = 0;
int tmp_read_bytes;
+ size_t remaining = SG(request_info).content_length - SG(read_post_bytes);
- count_bytes = MIN(count_bytes, (uint) SG(request_info).content_length - SG(read_post_bytes));
+ if (remaining < count_bytes) {
+ count_bytes = remaining;
+ }
while (read_bytes < count_bytes) {
fcgi_request *request = (fcgi_request*) SG(server_context);
if (request_body_fd == -1) {