[master] fd80d9d PROXY1: Avoid AN() on malformed input.

Dag Haavi Finstad daghf at varnish-software.com
Tue Apr 28 16:35:19 CEST 2015


commit fd80d9d6da43150443fc96d4c9158ce539f15ee8
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date:   Tue Apr 28 16:35:07 2015 +0200

    PROXY1: Avoid AN() on malformed input.

diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c
index 6ddcae5..caae7eb 100644
--- a/bin/varnishd/proxy/cache_proxy_proto.c
+++ b/bin/varnishd/proxy/cache_proxy_proto.c
@@ -66,7 +66,8 @@ vpx_proto1(const struct worker *wrk, struct req *req)
 	VSL(SLT_Debug, req->sp->fd, "PROXY1");
 
 	q = strchr(req->htc->rxbuf_b, '\r');
-	AN(q);
+	if (!q)
+		return (-1);
 
 	*q++ = '\0';
 	/* Nuke the CRNL */
diff --git a/bin/varnishtest/tests/o00000.vtc b/bin/varnishtest/tests/o00000.vtc
index 6af0abc..2018225 100644
--- a/bin/varnishtest/tests/o00000.vtc
+++ b/bin/varnishtest/tests/o00000.vtc
@@ -157,3 +157,9 @@ client c1 {
 } -run
 delay .1
 
+# Malformed (missing \r)
+client c1 {
+       send "PROXY TCP4 1.2.3.4 5.6.7.8 1234 5678\n"
+       expect_close
+} -run
+delay .1



More information about the varnish-commit mailing list