Skip to content

Fix GH-9949: Partial content on incomplete POST request #10059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sapi/apache2handler/sapi_apache2.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ php_apache_sapi_read_post(char *buf, size_t count_bytes)
php_struct *ctx = SG(server_context);
request_rec *r;
apr_bucket_brigade *brigade;
apr_status_t status;

r = ctx->r;
brigade = ctx->brigade;
Expand All @@ -193,7 +194,7 @@ php_apache_sapi_read_post(char *buf, size_t count_bytes)
* need to make sure that if data is available we fill the buffer completely.
*/

while (ap_get_brigade(r->input_filters, brigade, AP_MODE_READBYTES, APR_BLOCK_READ, len) == APR_SUCCESS) {
while ((status = ap_get_brigade(r->input_filters, brigade, AP_MODE_READBYTES, APR_BLOCK_READ, len)) == APR_SUCCESS) {
apr_brigade_flatten(brigade, buf, &len);
apr_brigade_cleanup(brigade);
tlen += len;
Expand All @@ -204,6 +205,10 @@ php_apache_sapi_read_post(char *buf, size_t count_bytes)
len = count_bytes - tlen;
}

if (status != APR_SUCCESS) {
return 0;
}

return tlen;
}

Expand Down