From 2abb616cca12f8c4908af2e657483bea8f8c31fd Mon Sep 17 00:00:00 2001 From: Tim Siebels Date: Thu, 23 Sep 2021 16:10:40 +0200 Subject: [PATCH] Fixed request bodies for chunked encoding in fcgi-cgi (fixes #51191) --- sapi/cgi/cgi_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 499a7932bed17..c4f5b447f54c0 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -504,11 +504,7 @@ static size_t sapi_fcgi_read_post(char *buffer, size_t count_bytes) size_t 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); - if (remaining < count_bytes) { - count_bytes = remaining; - } while (read_bytes < count_bytes) { size_t diff = count_bytes - read_bytes; int to_read = (diff > INT_MAX) ? INT_MAX : (int)diff; @@ -518,6 +514,10 @@ static size_t sapi_fcgi_read_post(char *buffer, size_t count_bytes) break; } read_bytes += tmp_read_bytes; + + if (fcgi_is_eof(request)) { + break; + } } return read_bytes; }