r3203 - in trunk/varnish-cache/bin: varnishd varnishtest/tests

phk at projects.linpro.no phk at projects.linpro.no
Fri Sep 19 18:27:44 CEST 2008


Author: phk
Date: 2008-09-19 18:27:44 +0200 (Fri, 19 Sep 2008)
New Revision: 3203

Added:
   trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Don't crash if the backend sends only "HTTP/1.1 200" with no reason string.

Fixes #325



Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2008-09-19 12:17:28 UTC (rev 3202)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2008-09-19 16:27:44 UTC (rev 3203)
@@ -432,13 +432,15 @@
 	for (; vct_issp(*p); p++)
 		;
 
-	/* Second field cannot contain SP, CRLF or CTL */
+	/* Second field cannot contain LWS */
 	hp->hd[h2].b = p;
-	for (; !vct_issp(*p); p++)
-		if (vct_isctl(*p))
-			return (400);
+	for (; !vct_islws(*p); p++)
+		;
 	hp->hd[h2].e = p;
 
+	if (!Tlen(hp->hd[h2]))
+		return (400);
+
 	/* Skip SP */
 	for (; vct_issp(*p); p++)
 		;
@@ -520,7 +522,8 @@
 		hp->status = 
 		    strtoul(hp->hd[HTTP_HDR_STATUS].b, NULL /* XXX */, 10);
 	}
-	if (!Tlen(hp->hd[HTTP_HDR_RESPONSE])) {
+	if (hp->hd[HTTP_HDR_RESPONSE].b == NULL ||
+	    !Tlen(hp->hd[HTTP_HDR_RESPONSE])) {
 		/* Backend didn't send a response string, use the standard */
 		hp->hd[HTTP_HDR_RESPONSE].b = 
 		    TRUST_ME(http_StatusMessage(hp->status));

Added: trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc	2008-09-19 16:27:44 UTC (rev 3203)
@@ -0,0 +1,37 @@
+# $Id$
+
+test "Check lack of response-string"
+
+server s1 {
+	rxreq
+	send "HTTP/1.1 200 \r\n"
+	send "Connection: close\r\n"
+	send "\r\n"
+	send "\r\n"
+	send "FOO\r\n"
+} -start
+
+varnish v1 -vcl+backend {} -start
+
+client c1 {
+	txreq -url /bar
+	rxresp
+	expect resp.status == 200
+	expect resp.msg == OK
+} -run
+
+server s1 {
+	rxreq
+	send "HTTP/1.1 200\r\n"
+	send "Connection: close\r\n"
+	send "\r\n"
+	send "\r\n"
+	send "FOO\r\n"
+} -start
+
+client c1 {
+	txreq -url /foo
+	rxresp
+	expect resp.status == 200
+	expect resp.msg == OK
+} -run


Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc
___________________________________________________________________
Name: svn:mergeinfo
   + 




More information about the varnish-commit mailing list