]> granicus.if.org Git - php/commitdiff
fix limitation of upload size == (U)INT_MAX in CGI
authorMichael Wallner <mike@php.net>
Fri, 25 Oct 2013 07:42:54 +0000 (09:42 +0200)
committerMichael Wallner <mike@php.net>
Mon, 28 Oct 2013 06:37:47 +0000 (07:37 +0100)
sapi/cgi/cgi_main.c
sapi/fpm/fpm/fpm_main.c

index 221b0021756dc11c3638ce69f473463f946b8fd1..43816d4d13a9b2245d98181049b9b147f09c2801 100644 (file)
@@ -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) {
index 4b20e632dd361bc9b7bd46f5d58e27116f2663a2..91abfea959f3ad972e497329c9bfc4b55412138a 100644 (file)
@@ -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) {