]> git.ipfire.org Git - thirdparty/squid.git/commit
Throw instead of asserting on some String overflows.
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 19 Feb 2016 21:23:08 +0000 (14:23 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 19 Feb 2016 21:23:08 +0000 (14:23 -0700)
commit70df76e30151bb5fd2070a275e2489ee6bdaaea9
tree1e9dae5b0fe509f16be3fcf41930e0b33274a15a
parent262eaf9a60fa26b03c4a66d145b880e72aa7718b
Throw instead of asserting on some String overflows.

Note that Client-caught exceptions result in HTTP 500 (Internal Server
Error) responses with X-Squid-Error set to "ERR_CANNOT_FORWARD 0".

Also avoid stuck Client jobs on exceptions. See trunk r8266 for a
similar fix with a detailed discussion. Here, I added doneWithFwd
instead of setting fwd to NULL because we dereference fwd (and store
pointers to things stored in fwd!) in many places. I think it is too
risky to just clear refcounted FwdState pointer (except in the
destructor where doing so is pointless).

Using doneWithFwd correctly is difficult because there are many ways we
can be "done" with FwdState, including:

    * calling fwd->complete(),
    * calling fwd->handleUnregisteredServerEnd(), and
    * closing the connection that FwdState monitors for closures.

The latter is especially tricky case because the closing is initiated in
many places, the process is asynchronous, and not all control
connections are monitored by FwdState.

For example, the updated control connection closure handler assumes that
it is being used for either external closures or internal closures
incorrectly used instead of mustStop()/abortAll(). In both cases, either
FwdState is still monitoring the connection (OK) or we forgot to call
one of its "done" methods listed above before closing. The latter would
be a bug, but I did not find any signs of it and fixing it would be
outside this change scope anyway.

Also unified String size limit checks [that I could find].
src/SquidString.h
src/StrList.cc
src/String.cc
src/clients/Client.cc
src/clients/Client.h
src/clients/FtpClient.cc
src/http.cc