]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Backport r581117
authorNick Kew <niq@apache.org>
Sun, 7 Oct 2007 14:14:32 +0000 (14:14 +0000)
committerNick Kew <niq@apache.org>
Sun, 7 Oct 2007 14:14:32 +0000 (14:14 +0000)
Default to NOT setting Max-Forwards in violation of RFC2616
PR 16137

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@582635 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
docs/manual/mod/mod_proxy.xml
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h

diff --git a/CHANGES b/CHANGES
index 07fa8e19db4fd208fca4fc19976263988d053a4c..e98bf38eca2c5b3c141e3fbf8487793cc8fd76d3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,11 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.7
 
+  *) mod_proxy: Don't by default violate RFC2616 by setting
+     Max-Forwards when the client didn't send it to us.
+     Leave that as a configuration option.
+     PR 16137 [Nick Kew]
+
   *) scoreboard: improve error message on apr_shm_create failure
      PR 40037 [Nick Kew]
 
diff --git a/STATUS b/STATUS
index 7f17d9d53365afd93fd46823310e3fb31dca2dd3..f98c4173067fb4167a7508176b8d3fc7b6f8376b 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -79,15 +79,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   * mod_proxy: Don't by default violate RFC2616 by setting
-     Max-Forwards when the client didn't send it to us.
-     PR 16137
-     http://svn.apache.org/viewvc?view=rev&revision=581117 (code)
-     http://svn.apache.org/viewvc?view=rev&revision=581253 (docs)
-     +1: niq, rpluem, trawick (who assumes that the "/2.3" in "default
-         behaviour changed in 2.2.7/2.3" will be stripped from trunk 
-         and 2.2.x as part of the backport operation)
-
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
 
index 2cc767dc856ee41e34dc9e1647a828229fa3a0ec..4eca8e0ad6ab15dc36b3e702241efe41d8835e3d 100644 (file)
@@ -1080,20 +1080,29 @@ connections</description>
 <description>Maximium number of proxies that a request can be forwarded
 through</description>
 <syntax>ProxyMaxForwards <var>number</var></syntax>
-<default>ProxyMaxForwards 10</default>
+<default>ProxyMaxForwards -1</default>
 <contextlist><context>server config</context><context>virtual host</context>
 </contextlist>
-<compatibility>Available in Apache 2.0 and later</compatibility>
+<compatibility>Available in Apache 2.0 and later;
+       default behaviour changed in 2.2.7</compatibility>
 
 <usage>
     <p>The <directive>ProxyMaxForwards</directive> directive specifies the
     maximum number of proxies through which a request may pass, if there's no
-    <code>Max-Forwards</code> header supplied with the request. This is
-    set to prevent infinite proxy loops, or a DoS attack.</p>
+    <code>Max-Forwards</code> header supplied with the request. This may
+    be set to prevent infinite proxy loops, or a DoS attack.</p>
 
     <example><title>Example</title>
       ProxyMaxForwards 15
     </example>
+
+    <p>Note that setting <directive>ProxyMaxForwards</directive> is a
+    violation of the HTTP/1.1 protocol (RFC2616), which forbids a Proxy
+    setting <code>Max-Forwards</code> if the Client didn't set it.
+    Earlier Apache versions would always set it.  A negative
+    <directive>ProxyMaxForwards</directive> value, including the
+    default -1, gives you protocol-compliant behaviour, but may
+    leave you open to loops.</p>
 </usage>
 </directivesynopsis>
 
index 33fb60d8fa20534a52a14c1ad5b063de8f56f98e..7a1aa14e92236dd975e6e00f7c024a02ad6ffd77 100644 (file)
@@ -692,8 +692,10 @@ static int proxy_handler(request_rec *r)
         /* set configured max-forwards */
         maxfwd = conf->maxfwd;
     }
-    apr_table_set(r->headers_in, "Max-Forwards",
-                  apr_psprintf(r->pool, "%ld", (maxfwd > 0) ? maxfwd : 0));
+    if (maxfwd > 0) {
+        apr_table_set(r->headers_in, "Max-Forwards",
+                      apr_psprintf(r->pool, "%ld", (maxfwd > 0) ? maxfwd : 0));
+    }
 
     if (r->method_number == M_TRACE) {
         core_server_config *coreconf = (core_server_config *)
@@ -1440,9 +1442,6 @@ static const char *
     proxy_server_conf *psf =
     ap_get_module_config(parms->server->module_config, &proxy_module);
     long s = atol(arg);
-    if (s < 0) {
-        return "ProxyMaxForwards must be greater or equal to zero..";
-    }
 
     psf->maxfwd = s;
     psf->maxfwd_set = 1;
index f2c89747887728742b2fd1dd9ec0df3cb225eef1..0f25caaff981295a9fef2710da385838b3ec5700 100644 (file)
@@ -94,7 +94,10 @@ enum enctype {
 #endif /*APR_CHARSET_EBCDIC*/
 
 /* default Max-Forwards header setting */
-#define DEFAULT_MAX_FORWARDS    10
+/* Set this to -1, which complies with RFC2616 by not setting
+ * max-forwards if the client didn't send it to us.
+ */
+#define DEFAULT_MAX_FORWARDS    -1
 
 /* static information about a remote proxy */
 struct proxy_remote {