]> granicus.if.org Git - apache/commitdiff
http_filters: make sure we get last byte of actual data in edge-case
authorNick Kew <niq@apache.org>
Wed, 9 Jan 2008 00:24:50 +0000 (00:24 +0000)
committerNick Kew <niq@apache.org>
Wed, 9 Jan 2008 00:24:50 +0000 (00:24 +0000)
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

index a5ff3ae8f1e3608348bdaa5be9f3f4710683ad28..f66650da6e061f93e1af1e50c9646880e01788e3 100644 (file)
@@ -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. */