[master] 77a8b1a Return PROTOCOL_ERROR for END_STREAM + content-length

Dag Haavi Finstad daghf at varnish-software.com
Mon Oct 23 10:45:07 UTC 2017


commit 77a8b1aca866ebc1efa1c164c5e961866f2cf191
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date:   Mon Oct 23 11:37:57 2017 +0200

    Return PROTOCOL_ERROR for END_STREAM + content-length

diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index f826136..0358acd 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -531,6 +531,8 @@ h2_end_headers(struct worker *wrk, struct h2_sess *h2,
 			req->req_body_status = REQ_BODY_WITH_LEN;
 	} else {
 		assert (req->req_body_status == REQ_BODY_NONE);
+		if (http_GetContentLength(req->http) > 0)
+			return (H2CE_PROTOCOL_ERROR); //rfc7540,l,1838,1840
 	}
 
 	req->req_step = R_STP_TRANSPORT;
diff --git a/bin/varnishtest/tests/r02305.vtc b/bin/varnishtest/tests/r02305.vtc
index d0bb78a..7da2d48 100644
--- a/bin/varnishtest/tests/r02305.vtc
+++ b/bin/varnishtest/tests/r02305.vtc
@@ -45,6 +45,27 @@ client c1 {
 	} -run
 } -run
 
+client c2 {
+	stream 1 {
+		txreq -hdr "content-length" "23"
+	} -run
+	stream 0 {
+		rxgoaway
+		expect goaway.err == PROTOCOL_ERROR
+		expect goaway.laststream == 1
+
+	} -run
+} -run
+
+# Allow content-length: 0
+client c2 {
+	stream 1 {
+		txreq -hdr "content-length" "0"
+		rxresp
+		expect resp.status == 200
+	} -run
+} -run
+
 varnish v1 -vsl_catchup
 varnish v1 -expect MEMPOOL.req0.live == 0
 varnish v1 -expect MEMPOOL.sess0.live == 0


More information about the varnish-commit mailing list