[7.7] 8ef69a03b req_fsm: Close the connection on a malformed request

Walid Boudebouda walid.boudebouda at gmail.com
Mon Mar 17 13:51:03 UTC 2025


commit 8ef69a03b36aeac5f364c01eb20f821860e47f14
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date:   Fri Jan 10 13:07:54 2025 +0100

    req_fsm: Close the connection on a malformed request

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 1004cbc5f..803810210 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -962,6 +962,7 @@ cnt_recv(struct worker *wrk, struct req *req)
 	if (http_CountHdr(req->http0, H_Host) > 1) {
 		VSLb(req->vsl, SLT_BogoHeader, "Multiple Host: headers");
 		wrk->stats->client_req_400++;
+		req->doclose = SC_RX_BAD;
 		(void)req->transport->minimal_response(req, 400);
 		return (REQ_FSM_DONE);
 	}
@@ -969,6 +970,7 @@ cnt_recv(struct worker *wrk, struct req *req)
 	if (http_CountHdr(req->http0, H_Content_Length) > 1) {
 		VSLb(req->vsl, SLT_BogoHeader, "Multiple Content-Length: headers");
 		wrk->stats->client_req_400++;
+		req->doclose = SC_RX_BAD;
 		(void)req->transport->minimal_response(req, 400);
 		return (REQ_FSM_DONE);
 	}
diff --git a/bin/varnishtest/tests/b00037.vtc b/bin/varnishtest/tests/b00037.vtc
index ce0e84112..e6185bd07 100644
--- a/bin/varnishtest/tests/b00037.vtc
+++ b/bin/varnishtest/tests/b00037.vtc
@@ -11,6 +11,7 @@ client c1 {
 
 varnish v1 -vsl_catchup
 varnish v1 -expect client_req_400 == 1
+varnish v1 -expect sc_rx_bad == 1
 
 client c1 {
 	txreq -method POST -hdr "Content-Length: 12" -hdr "Content-Length: 12" -bodylen 12
@@ -20,6 +21,7 @@ client c1 {
 
 varnish v1 -vsl_catchup
 varnish v1 -expect client_req_400 == 2
+varnish v1 -expect sc_rx_bad == 2
 
 varnish v1 -cliok "param.set feature +http2"
 


More information about the varnish-commit mailing list