]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Abort parse cleanly if there is nothing to do
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 31 Mar 2015 13:58:50 +0000 (06:58 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 31 Mar 2015 13:58:50 +0000 (06:58 -0700)
ICAP behaviour on noteMoreBodySpaceAvailable() can result in a parse
being attempted even if the read I/O buffer has not yet received any
new content to fill the available space. Handle this cleanly instead of
throwing parse errors and causing ICAP service disconnect.

src/http/one/ChunkedCodingParser.cc

index adcd376fa34f2fe968e64065e681bc17ca48f233..41d50ff10ffd85324c1b38b03111df710fa4093b 100644 (file)
@@ -36,8 +36,13 @@ Http::One::ChunkedCodingParser::clear()
 bool
 Http::One::ChunkedCodingParser::parse(const SBuf &aBuf)
 {
-    buf_ = aBuf;
+    buf_ = aBuf; // sync buffers first so calls to remaining() work properly if nothing done.
+
+    if (buf_.isEmpty()) // nothing to do (yet)
+        return false;
+
     debugs(74, DBG_DATA, "Parse buf={length=" << aBuf.length() << ", data='" << aBuf << "'}");
+
     Must(!buf_.isEmpty() && theOut);
 
     if (parsingStage_ == Http1::HTTP_PARSE_NONE)