[master] b47e278ae range: Don't panic in the absence of a range header

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Aug 31 10:23:07 UTC 2021


commit b47e278ae5c9dfc0ff09d773390afadd188f1923
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Aug 30 18:16:47 2021 +0200

    range: Don't panic in the absence of a range header
    
    That's just another case of falling back to regular delivery if the VCL
    mistakenly attempts to set up a range filter.

diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c
index 20f326455..cecc1efdb 100644
--- a/bin/varnishd/cache/cache_range.c
+++ b/bin/varnishd/cache/cache_range.c
@@ -117,7 +117,7 @@ vrg_dorange(struct req *req, void **priv)
 	assert(high >= -1);
 
 	if (low < 0) {
-		if (req->resp_len < 0)
+		if (req->resp_len < 0 || high < 0)
 			return (NULL);		// Allow 200 response
 		assert(high > 0);
 		low = req->resp_len - high;
@@ -228,7 +228,6 @@ vrg_range_init(struct vdp_ctx *vdc, void **priv, struct objcore *oc)
 	(void)oc;
 	req = vdc->req;
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-	assert(http_GetHdr(req->http, H_Range, NULL));
 	if (!vrg_ifrange(req))		// rfc7233,l,455,456
 		return (1);
 	err = vrg_dorange(req, priv);
diff --git a/bin/varnishtest/tests/c00034.vtc b/bin/varnishtest/tests/c00034.vtc
index 44773ffe2..d34b91cbe 100644
--- a/bin/varnishtest/tests/c00034.vtc
+++ b/bin/varnishtest/tests/c00034.vtc
@@ -274,3 +274,23 @@ client c8 {
 	rxresp
 	expect resp.status == 503
 } -run
+
+# range filter without a range header
+
+server s1 {
+	rxreq
+	txresp -bodylen 256
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_deliver {
+		set resp.filters = "range";
+	}
+}
+
+client c1 {
+	txreq -url /5
+	rxresp
+	expect resp.status == 200
+	expect resp.bodylen == 256
+} -run


More information about the varnish-commit mailing list