From: Justin Erenkrantz Date: Thu, 30 May 2002 23:13:16 +0000 (+0000) Subject: - Fix case where the initial chunk length was 0 was not handled correctly. X-Git-Tag: 2.0.37~151 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=49304500132617f29c53335d5a34dbb7a423f57d;p=apache - Fix case where the initial chunk length was 0 was not handled correctly. - Fix bucket lifetimes so that they don't live longer than their brigades. That's not nice. - Simplify some usage of f->r->connection to f->c in the bucket creation calls. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95416 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 1fc2a666e9..fec8be96ef 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -813,10 +813,9 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, " of %" APR_OFF_T_FMT, ctx->remaining, ctx->limit); bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc); e = ap_bucket_error_create(HTTP_REQUEST_ENTITY_TOO_LARGE, NULL, - f->r->connection->pool, - f->r->connection->bucket_alloc); + f->r->pool, f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); - e = apr_bucket_eos_create(f->r->connection->bucket_alloc); + e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); return ap_pass_brigade(f->r->output_filters, bb); } @@ -834,7 +833,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, * proxied *response*, proxy responses MUST be exempt. */ if (ctx->state == BODY_NONE && f->r->proxyreq != PROXYREQ_RESPONSE) { - e = apr_bucket_eos_create(f->r->connection->bucket_alloc); + e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(b, e); return APR_SUCCESS; } @@ -878,25 +877,33 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ctx->remaining = get_chunk_size(line); /* Detect chunksize error (such as overflow) */ if (ctx->remaining < 0) { - apr_brigade_cleanup(bb); + bb = apr_brigade_create(f->c->pool, f->c->bucket_alloc); e = ap_bucket_error_create(HTTP_REQUEST_ENTITY_TOO_LARGE, NULL, - f->r->connection->pool, - f->r->connection->bucket_alloc); + f->r->pool, + f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); - e = apr_bucket_eos_create(f->r->connection->bucket_alloc); + e = apr_bucket_eos_create(f->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; + ap_get_mime_headers(f->r); + e = apr_bucket_eos_create(f->c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(b, e); + return APR_SUCCESS; + } } } if (!ctx->remaining) { - conn_rec *c = f->r->connection; switch (ctx->state) { case BODY_NONE: break; case BODY_LENGTH: - e = apr_bucket_eos_create(c->bucket_alloc); + e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(b, e); return APR_SUCCESS; case BODY_CHUNK: @@ -929,9 +936,10 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, if (ctx->remaining < 0) { apr_brigade_cleanup(bb); e = ap_bucket_error_create(HTTP_REQUEST_ENTITY_TOO_LARGE, - NULL, c->pool, c->bucket_alloc); + NULL, f->r->pool, + f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); - e = apr_bucket_eos_create(c->bucket_alloc); + e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); return ap_pass_brigade(f->r->output_filters, bb); } @@ -940,7 +948,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, /* Handle trailers by calling ap_get_mime_headers again! */ ctx->state = BODY_NONE; ap_get_mime_headers(f->r); - e = apr_bucket_eos_create(c->bucket_alloc); + e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(b, e); return APR_SUCCESS; } @@ -988,10 +996,10 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, " of %" APR_OFF_T_FMT, ctx->limit_used, ctx->limit); bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc); e = ap_bucket_error_create(HTTP_REQUEST_ENTITY_TOO_LARGE, NULL, - f->r->connection->pool, - f->r->connection->bucket_alloc); + f->r->pool, + f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); - e = apr_bucket_eos_create(f->r->connection->bucket_alloc); + e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); return ap_pass_brigade(f->r->output_filters, bb); }