[master] 0577f3f RFC7230/3.2.4 compliance.
Poul-Henning Kamp
phk at FreeBSD.org
Thu Jun 30 10:58:09 CEST 2016
commit 0577f3fba200e45c05099427eec01610ee061436
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Jun 30 08:56:22 2016 +0000
RFC7230/3.2.4 compliance.
Spotted by: Régis Leroy
diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c
index f5dbe53..a6934e7 100644
--- a/bin/varnishd/http1/cache_http1_proto.c
+++ b/bin/varnishd/http1/cache_http1_proto.c
@@ -185,6 +185,18 @@ http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc,
(int)(q - p > 20 ? 20 : q - p), p);
return (400);
}
+
+ for (; p < q; p++) {
+ if (vct_islws(*p)) {
+ VSLb(hp->vsl, SLT_BogoHeader,
+ "Space in header '%.*s'",
+ (int)Tlen(hp->hd[hp->nhd - 1]),
+ hp->hd[hp->nhd - 1].b);
+ return (400);
+ }
+ if (*p == ':')
+ break;
+ }
}
if (p < htc->rxbuf_e)
p += vct_skipcrlf(p);
diff --git a/bin/varnishtest/tests/b00049.vtc b/bin/varnishtest/tests/b00049.vtc
new file mode 100644
index 0000000..7d2e289
--- /dev/null
+++ b/bin/varnishtest/tests/b00049.vtc
@@ -0,0 +1,32 @@
+varnishtest "RFC 7230 compliance"
+
+server s1 {
+ rxreq
+ txresp -gzipbody "FOOOOOOBAR"
+} -start
+
+varnish v1 -vcl+backend { } -start
+
+client c1 {
+ send "GET / HTTP/1.1\r\n"
+ send "Host: foo\r\n"
+ send "\r\n"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 10
+
+ send "GET / HTTP/1.1\r\n"
+ send "Host: foo\r\n"
+ send "Accept-Encoding: gzip\r\n"
+ send "\r\n"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 33
+
+ send "GET / HTTP/1.1\r\n"
+ send "Host: foo\r\n"
+ send "Accept-Encoding : gzip\r\n"
+ send "\r\n"
+ rxresp
+ expect resp.status == 400
+} -run
More information about the varnish-commit
mailing list