From def8b3422fc16de4b172cdd29022d039ca3db8aa Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 10 Jan 2009 22:11:26 +0000 Subject: [PATCH] If we get more HTTP headers than we have room for (default: 28) we used to ignore the rest. This is not a bright solution if crucial HTTP headers like "Content-Length" or "Transfer-Encoding" are last and get ignored. In general, it is highly suspect to randomly ignore HTTP headers, as opposed to deliberately ignoring them, either by having first looked at them and found them uninteresting, or by having looked for the headers we care about, and having not matched some others. Change too many headers to firm error condition: 400 if from the client, and 503 (like every other trouble) if from the backend. Fixes #416 git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3498 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_http.c | 1 + .../bin/varnishtest/tests/v00416.vtc | 102 ++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 varnish-cache/bin/varnishtest/tests/v00416.vtc diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index fbafdbdb..19d29cd2 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -354,6 +354,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, int fd, char *p, txt t) } else { VSL_stats->losthdr++; WSL(w, SLT_LostHeader, fd, "%.*s", q - p, p); + return (400); } } return (0); diff --git a/varnish-cache/bin/varnishtest/tests/v00416.vtc b/varnish-cache/bin/varnishtest/tests/v00416.vtc new file mode 100644 index 00000000..547da935 --- /dev/null +++ b/varnish-cache/bin/varnishtest/tests/v00416.vtc @@ -0,0 +1,102 @@ +# $Id$ + +test "Regression test for #416: a surplus of HTTP headers" + +server s1 { + rxreq + txresp \ + -hdr hdr00=00 \ + -hdr hdr01=01 \ + -hdr hdr02=02 \ + -hdr hdr03=03 \ + -hdr hdr04=04 \ + -hdr hdr05=05 \ + -hdr hdr06=06 \ + -hdr hdr07=07 \ + -hdr hdr08=08 \ + -hdr hdr09=09 \ + -hdr hdr10=10 \ + -hdr hdr11=11 \ + -hdr hdr12=12 \ + -hdr hdr13=13 \ + -hdr hdr14=14 \ + -hdr hdr15=15 \ + -hdr hdr16=16 \ + -hdr hdr17=17 \ + -hdr hdr18=18 \ + -hdr hdr19=19 \ + -hdr hdr20=20 \ + -hdr hdr21=21 \ + -hdr hdr22=22 \ + -hdr hdr23=23 \ + -hdr hdr24=24 \ + -hdr hdr25=25 \ + -hdr hdr26=26 \ + -hdr hdr27=27 \ + -hdr hdr28=28 \ + -hdr hdr29=29 \ + -hdr hdr30=30 \ + -hdr hdr31=31 \ + -hdr hdr32=32 \ + -hdr hdr33=33 \ + -hdr hdr34=34 \ + -hdr hdr35=35 \ + -hdr hdr36=36 \ + -hdr hdr37=37 \ + -hdr hdr38=38 \ + -hdr hdr39=39 \ + -body "foo" +} -start + +varnish v1 -vcl+backend {} -start + +client c1 { + txreq \ + -hdr hdr00=00 \ + -hdr hdr01=01 \ + -hdr hdr02=02 \ + -hdr hdr03=03 \ + -hdr hdr04=04 \ + -hdr hdr05=05 \ + -hdr hdr06=06 \ + -hdr hdr07=07 \ + -hdr hdr08=08 \ + -hdr hdr09=09 \ + -hdr hdr10=10 \ + -hdr hdr11=11 \ + -hdr hdr12=12 \ + -hdr hdr13=13 \ + -hdr hdr14=14 \ + -hdr hdr15=15 \ + -hdr hdr16=16 \ + -hdr hdr17=17 \ + -hdr hdr18=18 \ + -hdr hdr19=19 \ + -hdr hdr20=20 \ + -hdr hdr21=21 \ + -hdr hdr22=22 \ + -hdr hdr23=23 \ + -hdr hdr24=24 \ + -hdr hdr25=25 \ + -hdr hdr26=26 \ + -hdr hdr27=27 \ + -hdr hdr28=28 \ + -hdr hdr29=29 \ + -hdr hdr30=30 \ + -hdr hdr31=31 \ + -hdr hdr32=32 \ + -hdr hdr33=33 \ + -hdr hdr34=34 \ + -hdr hdr35=35 \ + -hdr hdr36=36 \ + -hdr hdr37=37 \ + -hdr hdr38=38 \ + -hdr hdr39=39 + rxresp +} -run + +client c1 { + txreq + rxresp + expect resp.status == 503 +} -run -- 2.39.5