Skip to content

Commit

Permalink
Fixed request bodies for chunked encoding in fcgi-cgi (fixes #51191)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Siebels committed Nov 24, 2021
1 parent 7b5f6a3 commit aff52e9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sapi/cgi/cgi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit aff52e9

Please sign in to comment.