]> git.ipfire.org Git - thirdparty/squid.git/commit
Fix helper buffer management
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 8 Dec 2012 01:50:46 +0000 (14:50 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 8 Dec 2012 01:50:46 +0000 (14:50 +1300)
commitec682a26847422effbbd93bf9942c6ce67f24472
tree8e9e92b85b45915f10cb3e668a2ad1c043f18799
parent46901eed7c0a8de80bbddeee254af24ec4d14183
Fix helper buffer management

Identified by Tsantilas Christos.

"One byte remains in helpers io buffer after parsing the response. This is
will cause problems when the next response from helper will enter squid.

After the  srv->rbuf parsed, the srv->rbuf still contains on byte (a '\0'
char) and the srv->roffset is 1."

Perform memmove() in helperHandleRead() instead of helperReturnBuffer()

* helperReturnBuffer is only dealing with the message sub-string, but has
  been made to memmove() the buffer contents which means it has to become
  aware of these problematic terminal \0 octet(s). However
  helperHandleRead() is where the termination is being done and the
  buffer information is all being handled.

Pass the first of the termination \0 octets to helperReturnBuffer() not
the last \0. This is made possible after fixing (1a).

* helpers which return \r\n were still passing the location of the \n as
  endpoint to workaround (1a) even though the \r is also replaced with
  \0 and shortens the msg portion by one octet. This affects the
  HelperReply parser length checks on responses without kv-pair.

Also, clear out an obsolete TODO.

Also, document a remaining design issue in stateful helpers assuming each
read() operation is on response and ignoring any octets in the buffer
after parsing one reply.
src/helper.cc