]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* modules/ssl/ssl_engine_io.c (ssl_io_filter_coalesce): Handle the case
authorRuediger Pluem <rpluem@apache.org>
Wed, 1 Apr 2020 19:30:49 +0000 (19:30 +0000)
committerRuediger Pluem <rpluem@apache.org>
Wed, 1 Apr 2020 19:30:49 +0000 (19:30 +0000)
  where apr_bucket_read fails with an error and hence our current bucket
  remains the morphing bucket and is not replaced with a 'data' bucket.
  If the error is not EAGAINi, error out with an AP_FILTER_ERROR,
  otherwise just do not consider the morphing bucket that has no data for
  coalesce.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1876014 13f79535-47bb-0310-9956-ffa450edef68

modules/ssl/ssl_engine_io.c

index 35ccc14ec5666ba48bbe2e8db4da2da16b12b71e..4880c5b6a23858f60000e870f9481c61cebb5326 100644 (file)
@@ -1739,7 +1739,7 @@ static apr_status_t ssl_io_filter_coalesce(ap_filter_t *f,
         && bytes + buffered < COALESCE_BYTES
         && e != APR_BRIGADE_SENTINEL(bb)
         && !APR_BUCKET_IS_METADATA(e)) {
-        apr_status_t rv;
+        apr_status_t rv = APR_SUCCESS;
 
         /* For an indeterminate length bucket (PIPE/CGI/...), try a
          * non-blocking read to have it morph into a HEAP.  If the
@@ -1753,38 +1753,38 @@ static apr_status_t ssl_io_filter_coalesce(ap_filter_t *f,
             if (rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv)) {
                 ap_log_cerror(APLOG_MARK, APLOG_ERR, rv, f->c, APLOGNO(10232)
                               "coalesce failed to read from data bucket");
+                return AP_FILTER_ERROR;
             }
         }
 
-        /* If the read above made the bucket morph, it may now fit
-         * entirely within the buffer.  Otherwise, split it so it does
-         * fit. */
-        if (e->length < COALESCE_BYTES
-            && e->length + buffered + bytes < COALESCE_BYTES) {
-            rv = APR_SUCCESS;
-        }
-        else {
-            rv = apr_bucket_split(e, COALESCE_BYTES - (buffered + bytes));
-        }
-
-        if (rv == APR_SUCCESS && e->length == 0) {
-            /* As above, don't count in the prefix if the bucket is
-             * now zero-length. */
-        }
-        else if (rv == APR_SUCCESS) {
-            ap_log_cerror(APLOG_MARK, APLOG_TRACE4, 0, f->c,
-                          "coalesce: adding %" APR_SIZE_T_FMT " bytes "
-                          "from split bucket, adding %" APR_SIZE_T_FMT,
-                          e->length, bytes + buffered);
+        if (rv == APR_SUCCESS) {
+            /* If the read above made the bucket morph, it may now fit
+             * entirely within the buffer.  Otherwise, split it so it does
+             * fit. */
+            if (e->length >= COALESCE_BYTES
+                || e->length + buffered + bytes >= COALESCE_BYTES) {
+                rv = apr_bucket_split(e, COALESCE_BYTES - (buffered + bytes));
+            }
 
-            count++;
-            bytes += e->length;
-            e = APR_BUCKET_NEXT(e);
-        }
-        else if (rv != APR_ENOTIMPL) {
-            ap_log_cerror(APLOG_MARK, APLOG_ERR, rv, f->c, APLOGNO(10233)
-                          "coalesce: failed to split data bucket");
-            return AP_FILTER_ERROR;
+            if (rv == APR_SUCCESS && e->length == 0) {
+                /* As above, don't count in the prefix if the bucket is
+                 * now zero-length. */
+            }
+            else if (rv == APR_SUCCESS) {
+                ap_log_cerror(APLOG_MARK, APLOG_TRACE4, 0, f->c,
+                              "coalesce: adding %" APR_SIZE_T_FMT " bytes "
+                              "from split bucket, adding %" APR_SIZE_T_FMT,
+                              e->length, bytes + buffered);
+
+                count++;
+                bytes += e->length;
+                e = APR_BUCKET_NEXT(e);
+            }
+            else if (rv != APR_ENOTIMPL) {
+                ap_log_cerror(APLOG_MARK, APLOG_ERR, rv, f->c, APLOGNO(10233)
+                              "coalesce: failed to split data bucket");
+                return AP_FILTER_ERROR;
+            }
         }
     }