apr_brigade_flatten(bb, line, &len);
ctx->remaining = get_chunk_size(line);
+ /* Detect invalid chunk sizes. */
+ if (ctx->remaining < 0) {
+ apr_brigade_cleanup(bb);
+ e = ap_bucket_error_create(HTTP_REQUEST_ENTITY_TOO_LARGE, NULL,
+ f->r->connection->pool,
+ f->r->connection->bucket_alloc);
+ APR_BRIGADE_INSERT_TAIL(bb, e);
+ e = apr_bucket_eos_create(f->r->connection->bucket_alloc);
+ APR_BRIGADE_INSERT_TAIL(bb, e);
+ return ap_pass_brigade(f->r->output_filters, bb);
+ }
}
}
apr_brigade_flatten(bb, line, &len);
ctx->remaining = get_chunk_size(line);
+ /* Detect invalid chunk sizes. */
+ if (ctx->remaining < 0) {
+ apr_brigade_cleanup(bb);
+ e = ap_bucket_error_create(HTTP_REQUEST_ENTITY_TOO_LARGE,
+ NULL, c->pool, c->bucket_alloc);
+ APR_BRIGADE_INSERT_TAIL(bb, e);
+ e = apr_bucket_eos_create(c->bucket_alloc);
+ APR_BRIGADE_INSERT_TAIL(bb, e);
+ return ap_pass_brigade(f->r->output_filters, bb);
+ }
+
if (!ctx->remaining) {
/* Handle trailers by calling ap_get_mime_headers again! */
ctx->state = BODY_NONE;
{
int rv;
+ /* Sometimes we'll get in a state where the input handling has
+ * detected an error where we want to drop the connection, so if
+ * that's the case, don't read the data as that is what we're trying
+ * to avoid.
+ *
+ * This function is also a no-op on a subrequest.
+ */
+ if (r->main || ap_status_drops_connection(r->status)) {
+ return OK;
+ }
+
if (r->read_length == 0) { /* if not read already */
if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK))) {
return rv;
r->status = HTTP_PROXY_AUTHENTICATION_REQUIRED;
}
- /*
- * If we want to keep the connection, be sure that the request body
- * (if any) has been read.
+ /* If we don't want to keep the connection, make sure we mark that the
+ * connection is not eligible for keepalive. If we want to keep the
+ * connection, be sure that the request body (if any) has been read.
*/
- if ((r->status != HTTP_NOT_MODIFIED) && (r->status != HTTP_NO_CONTENT)
- && !ap_status_drops_connection(r->status)
- && r->connection && (r->connection->keepalive != -1)) {
+ if (ap_status_drops_connection(r->status)) {
+ r->connection->keepalive = 0;
+ }
+ else if ((r->status != HTTP_NOT_MODIFIED) &&
+ (r->status != HTTP_NO_CONTENT) &&
+ r->connection && (r->connection->keepalive != -1)) {
(void) ap_discard_request_body(r);
}