httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1773865 - /httpd/httpd/trunk/modules/http/http_filters.c
Date Mon, 12 Dec 2016 20:31:44 GMT
Author: ylavic
Date: Mon Dec 12 20:31:44 2016
New Revision: 1773865

URL: http://svn.apache.org/viewvc?rev=1773865&view=rev
Log:
Follow up to r1773761: improved recursion detection.

Modified:
    httpd/httpd/trunk/modules/http/http_filters.c

Modified: httpd/httpd/trunk/modules/http/http_filters.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/http_filters.c?rev=1773865&r1=1773864&r2=1773865&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/http_filters.c (original)
+++ httpd/httpd/trunk/modules/http/http_filters.c Mon Dec 12 20:31:44 2016
@@ -687,6 +687,20 @@ static APR_INLINE int check_headers(requ
            apr_table_do(check_header, &ctx, r->err_headers_out, NULL);
 }
 
+static int check_headers_recursion(request_rec *r)
+{
+    request_rec *rr;
+    for (rr = r; rr; rr = rr->prev) {
+        void *dying = NULL;
+        apr_pool_userdata_get(&dying, "check_headers_recursion", rr->pool);
+        if (dying) {
+            return 1;
+        }
+    }
+    apr_pool_userdata_setn("true", "check_headers_recursion", NULL, r->pool);
+    return 0;
+}
+
 typedef struct header_struct {
     apr_pool_t *pool;
     apr_bucket_brigade *bb;
@@ -1192,7 +1206,6 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_
     header_filter_ctx *ctx = f->ctx;
     const char *ctype;
     ap_bucket_error *eb = NULL;
-    void *dying = NULL;
     int eos = 0;
 
     AP_DEBUG_ASSERT(!r->main);
@@ -1208,7 +1221,6 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_
         }
     }
     else if (!ctx->headers_error && !check_headers(r)) {
-        apr_pool_userdata_get(&dying, "http_header_filter_dying", r->pool);
         ctx->headers_error = 1;
     }
     for (e = APR_BRIGADE_FIRST(b);
@@ -1249,14 +1261,13 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_
         apr_table_clear(r->headers_out);
         apr_table_clear(r->err_headers_out);
 
-        /* Don't try ErrorDocument if we are (internal-)redirect-ed or dying
-         * already, otherwise we can end up in infinite recursion, better fall
-         * through with 500, minimal headers and an empty body (EOS only).
+        /* Don't recall ap_die() if we come back here (from its own internal
+         * redirect or error response), otherwise we can end up in infinite
+         * recursion; better fall through with 500, minimal headers and an
+         * empty body (EOS only).
          */
-        if (ap_is_initial_req(r) && !dying) {
+        if (!check_headers_recursion(r)) {
             apr_brigade_cleanup(b);
-            apr_pool_userdata_setn("true", "http_header_filter_dying",
-                                   apr_pool_cleanup_null, r->pool);
             ap_die(HTTP_INTERNAL_SERVER_ERROR, r);
             return AP_FILTER_ERROR;
         }



Mime
View raw message