]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy_http: don't strip EOS when spooling request body to file.
authorYann Ylavic <ylavic@apache.org>
Fri, 29 May 2020 17:05:29 +0000 (17:05 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 29 May 2020 17:05:29 +0000 (17:05 +0000)
To prevent stream_reqbody() from sending the FILE and EOS bucket in separate
brigades, and thus apr_file_setaside() to trigger if network congestion occurs
with the backend, restore the EOS in spool_reqbody_cl() which was stripped
when spooling the request body to a file.

Until APR r1878279 is released (and installed by users), apr_file_setaside()
on a temporary file (mktemp) will simply drop the file cleanup, leaking the
fd and inode..

This fixes BZ 64452.

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

CHANGES
modules/proxy/mod_proxy_http.c

diff --git a/CHANGES b/CHANGES
index 161a9b442bec3923e59138b7cb2f52dd961c5be3..6def068a9d5a405875a9d3c0a4034a8674bcb34c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.1
 
+  *) mod_proxy_http: flush spooled request body in one go to avoid
+     leaking (or long lived) temporary file. PR 64452. [Yann Ylavic]
+
   *) mod_proxy_http2: respect ProxyTimeout settings on backend connections
      while waiting on incoming data. [Ruediger Pluem, Stefan Eissing]
 
index f2857439d20a21fc9f6914868d2eec7d2c21fa66..a4be4ee336a9af53b7daf2c724cba5d09c9a05f9 100644 (file)
@@ -549,6 +549,14 @@ static int spool_reqbody_cl(proxy_http_req_t *req, apr_off_t *bytes_spooled)
         e = apr_bucket_immortal_create(CRLF_ASCII, 2, bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(input_brigade, e);
     }
+    if (tmpfile) {
+        /* We dropped metadata buckets when spooling to tmpfile,
+         * terminate with EOS for stream_reqbody() to flush the
+         * whole in one go.
+         */
+        e = apr_bucket_eos_create(bucket_alloc);
+        APR_BRIGADE_INSERT_TAIL(input_brigade, e);
+    }
     return OK;
 }