]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 419: Hop by Hop headers MUST NOT be forwarded (attempt 2)
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 9 Feb 2009 05:33:18 +0000 (18:33 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 9 Feb 2009 05:33:18 +0000 (18:33 +1300)
This attempt builds on Henriks re-work of the client-request to
server-request cloning done since the last attempt was made at closing
this bug.

Adds all RFC 2616 listed Hop-by-hop headers to the clone selection test
as 'ignore' cases unless otherwise handled already.

The test for whether they exist in Connection: is moved to the default
case as an inline. Which reduces the code a fair bit and prevents the
side case where a specially handled header gets ignored because the
client explicitly added it to Connection: when it did not have to.

This method sets up a background default of not passing the hop-by-hop
headers while allowing any code which explicitly sets or copies the
headers across to operate as before without interference.

1  2 
src/HttpRequest.cc
src/HttpRequest.h
src/http.cc

index 399659f2a08b43488d6ac71cf2d2483cb9112dd5,f74dd0c453382f0fe305f4fd40d0c3ceb1b25832..c575684a47b6de020ec4ef9ec04f4591a4cebe6a
@@@ -326,22 -326,24 +326,6 @@@ HttpRequest::prefixLen(
             header.len + 2;
  }
  
 -#if DEAD_CODE // 2009-01-20: inlined this with its ONLY caller (copyOneHeader...)
--/**
-- * Returns true if HTTP allows us to pass this header on.  Does not
-- * check anonymizer (aka header_access) configuration.
-- */
--int
--httpRequestHdrAllowed(const HttpHeaderEntry * e, String * strConn)
--{
--    assert(e);
--    /* check connection header */
--
-     if (strConn && strListIsMember(strConn, e->name.termedBuf(), ','))
 -    if (strConn && strListIsMember(strConn, e->name.buf(), ','))
--        return 0;
--
--    return 1;
--}
 -#endif
--
  /* sync this routine when you update HttpRequest struct */
  void
  HttpRequest::hdrCacheInit()
index 455bd74c8b750cead47d822d763d0c7145f43dde,86c67a6f86a42867e1803b5f14a4f98cd003b47e..402450ab896d547cd662eb95fdfce23b1e0bf7e1
@@@ -40,8 -40,8 +40,7 @@@
  #include "HttpRequestMethod.h"
  
  /*  Http Request */
--extern int httpRequestHdrAllowed(const HttpHeaderEntry * e, String * strConnection);
--extern int httpRequestHdrAllowedByName(http_hdr_type id);
++//DEAD?: extern int httpRequestHdrAllowedByName(http_hdr_type id);
  extern void httpRequestPack(void *obj, Packer *p);
  
  
diff --cc src/http.cc
index d2224092f25e9c1c56b278f4bc6488ea79304d17,5f38fd6c1f1eaa2706ed1c15abd97f1472dbe757..84ebc47b3e09cc1f55eed42ef3be2ac5827fb0f6
@@@ -1655,20 -1647,22 +1655,22 @@@ HttpStateData::httpBuildRequestHeader(H
      strConnection.clean();
  }
  
+ /**
+  * Decides whether a particular header may be cloned from the received Clients request
+  * to our outgoing fetch request.
+  */
  void
- copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, String strConnection, HttpRequest * request, HttpRequest * orig_request, HttpHeader * hdr_out, int we_do_ranges, http_state_flags flags)
+ copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, const String strConnection, HttpRequest * request, const HttpRequest * orig_request, HttpHeader * hdr_out, const int we_do_ranges, const http_state_flags flags)
  {
 -    debugs(11, 5, "httpBuildRequestHeader: " << e->name.buf() << ": " << e->value.buf());
 +    debugs(11, 5, "httpBuildRequestHeader: " << e->name << ": " << e->value );
  
-     if (!httpRequestHdrAllowed(e, &strConnection)) {
-         debugs(11, 2, "'" << e->name << "' header denied by anonymize_headers configuration");
-         return;
-     }
      switch (e->id) {
  
+ /** \title RFC 2616 sect 13.5.1 - Hop-by-Hop headers which Squid should not pass on. */
      case HDR_PROXY_AUTHORIZATION:
-         /* Only pass on proxy authentication to peers for which
+         /** \par Proxy-Authorization:
+          * Only pass on proxy authentication to peers for which
           * authentication forwarding is explicitly enabled
           */
  
          break;
  
      default:
-         /* pass on all other header fields */
+         /** \par default.
+          * pass on all other header fields
+          * which are NOT listed by the special Connection: header. */
+         if (strConnection.size()>0 && strListIsMember(&strConnection, e->name.buf(), ',')) {
 -            debugs(11, 2, "'" << e->name.buf() << "' header cropped by Connection: definition");
++            debugs(11, 2, "'" << e->name << "' header cropped by Connection: definition");
+             return;
+         }
          hdr_out->addEntry(e->clone());
      }
  }