]> git.ipfire.org Git - thirdparty/squid.git/commit - src/http.cc
Truncate too-long HTTP response bodies to match their Content-Length header.
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 2 Jul 2009 16:36:36 +0000 (10:36 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 2 Jul 2009 16:36:36 +0000 (10:36 -0600)
commit821beb5e424258ebdc604c75e5954088cd631c9c
tree497725d27eeb4bdd20217447e08c5085d58adc91
parentce5a16c28220fd02bda75be1652c157bf2c93bc8
Truncate too-long HTTP response bodies to match their Content-Length header.

Sometimes a broken server sends more than Content-Length bytes in the
response.  For example, a 302 redirect message with "Content-Length: 0" header
may include an HTML body. Squid used to send "everything" it read to the
client, even if it read more than the Content-Length bytes. That may have
helped in some cases, but we should be more conservative when dealing
with broken servers to combat message smuggling attacks and other bad
side-effects for clients.

We now do not forward more than the advertised content length and declare the
connection with a broken server non-persistent.

Chunked responses (that HTTP/1.0 Squid should not receive and that must not
have a Content-Length header) are not truncated because RFC 2616 says we
MUST ignore their Content-Length header.

TODO: Do not cache the truncated entry and purge the cached version, if any.
src/MemBuf.cc
src/MemBuf.h
src/http.cc
src/http.h