]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #1940: assertion failed: store.cc:850
authorrousskov <>
Wed, 25 Apr 2007 20:37:55 +0000 (20:37 +0000)
committerrousskov <>
Wed, 25 Apr 2007 20:37:55 +0000 (20:37 +0000)
Avoid calling writeReplyBody when there is no reply body data to write.

FtpStateData calls processReplyBody from several places. When called from
icapAclCheckDone we may not be expecting a body for this response. If no body
is expected, the store entry may not be in a STORE_PENDING state and when we
try to append [zero-sized] body data, the store asserts.

If no body is expected, we probably should not be calling processReplyBody!
Unfortunately, it was not obvious for me what we should call so I left the
call there and made it bypass store writing if there is no body content.

If you understand the FtpStateData logic, please try to make sure
processReplyBody is not called for objects without a body (it is possible that
something else should be called instead though). Please note that ICAP sets
virginBodyDestination when body is expected.

src/ftp.cc

index 1bd3bf809a450a530018c00d65b57e4974edf2fd..e73985d5eecff1ddd434439971314c50d1b297f8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.416 2007/04/23 17:50:49 wessels Exp $
+ * $Id: ftp.cc,v 1.417 2007/04/25 14:37:55 rousskov Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -1366,10 +1366,11 @@ FtpStateData::processReplyBody()
 
     if (flags.isdir) {
         parseListing();
-    } else {
-        writeReplyBody(data.readBuf->content(), data.readBuf->contentSize());
-        debugs(9,5,HERE << "consuming " << data.readBuf->contentSize() << " bytes of readBuf");
-        data.readBuf->consume(data.readBuf->contentSize());
+    } else 
+    if (const int csize = data.readBuf->contentSize()) {
+        writeReplyBody(data.readBuf->content(), csize);
+        debugs(9,5,HERE << "consuming " << csize << " bytes of readBuf");
+        data.readBuf->consume(csize);
     }
 
     entry->flush();