]> git.ipfire.org Git - thirdparty/squid.git/commit
HTTP: validate Content-Length header values
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 6 Sep 2016 02:45:20 +0000 (14:45 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 6 Sep 2016 02:45:20 +0000 (14:45 +1200)
commita1b9ec20f3249d0478b2357edad095c1cc3fbcf4
treecc873766915cd0cd3768a7ffb4f8f394d76abe38
parent3edd7ed8fd72801763d7f003d98cf65bf8a6764a
HTTP: validate Content-Length header values

Squid is violating HTTP MUSTs by forwarding messages with
problematic Content-Length values. Some of those bugs were fixed in
trunk r14215. This change handles multiple Content-Length values inside
one header field, negative values, and trailing garbage. Handling the
former required a change in the overall Content-Length interpretation
approach (which is why it was previously left as a TODO).

Squid now passes almost all Co-Advisor tests devoted to this area. We
are not 100% done though: We still need to handle malformed values with
leading signs (e.g., "-0" or "+1"). However, I hope that the remaining
problems are relatively minor. I do not plan on addressing them in the
foreseeable future.

Also improved httpHeaderParseOffset(): Added detection of overflowing
and underflowing integer values; polished malformed value detection code
(Linux strtoll(3) manual page has a good example). The function no
longer considers empty strings valid and reports trailing characters.
The function still accepts leading whitespace and signs. It is still the
wrong approach to HTTP numbers parsing, but further improvements are out
of scope because they are complicated and would require significant
caller rewrites.
src/HttpHeader.cc
src/HttpHeaderTools.cc
src/HttpHeaderTools.h
src/http/ContentLengthInterpreter.cc [new file with mode: 0644]
src/http/ContentLengthInterpreter.h [new file with mode: 0644]
src/http/Makefile.am
src/http/one/Parser.h