]> err.no Git - varnish/commitdiff
Don't crash if the backend sends only "HTTP/1.1 200" with no reason string.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 19 Sep 2008 16:27:44 +0000 (16:27 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 19 Sep 2008 16:27:44 +0000 (16:27 +0000)
Fixes #325

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3203 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_http.c
varnish-cache/bin/varnishtest/tests/r00325.vtc [new file with mode: 0644]

index a49d9fa2e2a01c975fa43b34534b84644855216b..18d50bb290719e50437e5fc4c2c411dc2166a959 100644 (file)
@@ -432,13 +432,15 @@ http_splitline(struct worker *w, int fd, struct http *hp, const struct http_conn
        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 @@ http_DissectResponse(struct worker *w, const struct http_conn *htc, struct http
                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));
diff --git a/varnish-cache/bin/varnishtest/tests/r00325.vtc b/varnish-cache/bin/varnishtest/tests/r00325.vtc
new file mode 100644 (file)
index 0000000..e3eabce
--- /dev/null
@@ -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