[master] 24a9a5698 Make sure all headers listed in `Connection:` are hop-to-hop

Poul-Henning Kamp phk at FreeBSD.org
Fri Jul 24 15:32:06 UTC 2020


commit 24a9a5698e15444aa48e0df8b66f98c2a499339d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jul 24 12:16:40 2020 +0000

    Make sure all headers listed in `Connection:` are hop-to-hop

diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index cf949b765..4af545b57 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -765,9 +765,16 @@ http_DoConnection(struct http *hp)
 #include "tbl/http_headers.h"
 /*lint -restore */
 
-		v = http_findhdr(hp, u, b);
-		if (v > 0)
+		for (v = HTTP_HDR_FIRST; v < hp->nhd; v++) {
+			Tcheck(hp->hd[v]);
+			if (hp->hd[v].e < hp->hd[v].b + u + 1)
+				continue;
+			if (hp->hd[v].b[u] != ':')
+				continue;
+			if (strncasecmp(b, hp->hd[v].b, u))
+				continue;
 			hp->hdf[v] |= HDF_FILTER;
+		}
 	}
 	return (retval);
 }
diff --git a/bin/varnishtest/tests/c00016.vtc b/bin/varnishtest/tests/c00016.vtc
index 847fb8730..8cbbfc79d 100644
--- a/bin/varnishtest/tests/c00016.vtc
+++ b/bin/varnishtest/tests/c00016.vtc
@@ -42,3 +42,27 @@ client c1 {
 	rxresp
 	expect resp.status == 400
 } -run
+
+server s1 {
+	rxreq
+	expect req.http.baa == ""
+	expect req.http.baax == <undef>
+	txresp -hdr "Foox: 1" -hdr "foox: 2" -hdr "Connection: foox"
+}  -start
+
+varnish v1 -vcl+backend {
+	sub vcl_backend_fetch {
+		set bereq.http.baa = bereq.http.baax;
+	}
+	sub vcl_deliver {
+		set resp.http.foo = resp.http.foox;
+	}
+} 
+
+client c1 {
+	txreq -hdr "Baax: 1" -hdr "Baax: 2" -hdr "Connection: baax"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.foo == ""
+	expect resp.http.foox == <undef>
+} -run


More information about the varnish-commit mailing list