From 9c07455cd7705eaae82c359bee009ab34c5638ee Mon Sep 17 00:00:00 2001 From: Nick Kew Date: Wed, 9 Jan 2008 00:24:50 +0000 Subject: [PATCH] http_filters: make sure we get last byte of actual data in edge-case of an empty data bucket in get_remaining_chunk_line. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@610240 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http/http_filters.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c index a5ff3ae8f1..f66650da6e 100644 --- a/modules/http/http_filters.c +++ b/modules/http/http_filters.c @@ -135,19 +135,23 @@ static apr_status_t get_remaining_chunk_line(http_ctx_t *ctx, e != APR_BRIGADE_SENTINEL(b); e = APR_BUCKET_PREV(e)) { - if (!APR_BUCKET_IS_METADATA(e)) { - break; + if (APR_BUCKET_IS_METADATA(e)) { + continue; + } + rv = apr_bucket_read(e, &lineend, &len, APR_BLOCK_READ); + if (rv != APR_SUCCESS) { + return rv; } + if (len > 0) { + break; /* we got the data we want */ + } + /* If we got a zero-length data bucket, we try the next one */ } - /* We only had META buckets in this brigade */ + /* We had no data in this brigade */ if (e == APR_BRIGADE_SENTINEL(b)) { return APR_EAGAIN; } - rv = apr_bucket_read(e, &lineend, &len, APR_BLOCK_READ); - if (rv != APR_SUCCESS) { - return rv; - } - if ((len == 0) || (lineend[len - 1] != APR_ASCII_LF)) { + if (lineend[len - 1] != APR_ASCII_LF) { return APR_EAGAIN; } /* Line is complete. So reset ctx->linesize for next round. */ -- 2.40.0