--------------------- PatchSet 1606 Date: 2005/08/25 21:11:33 Author: rousskov Branch: squid3-icap Tag: (none) Log: - Added assertions to catch negative memory offsets earlier. Members: src/MemObject.cc:1.15->1.15.8.1 src/store.cc:1.27.8.1->1.27.8.2 Index: squid3/src/MemObject.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/MemObject.cc,v retrieving revision 1.15 retrieving revision 1.15.8.1 diff -u -r1.15 -r1.15.8.1 --- squid3/src/MemObject.cc 4 Jan 2005 03:13:37 -0000 1.15 +++ squid3/src/MemObject.cc 25 Aug 2005 21:11:33 -0000 1.15.8.1 @@ -1,6 +1,6 @@ /* - * $Id: MemObject.cc,v 1.15 2005/01/04 03:13:37 squidadm Exp $ + * $Id: MemObject.cc,v 1.15.8.1 2005/08/25 21:11:33 rousskov Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Robert Collins @@ -139,6 +139,7 @@ { PROF_start(MemObject_write); debug(19, 6) ("memWrite: offset %lu len %ld\n", (unsigned long)writeBuffer.offset, (long)writeBuffer.length); + assert(0 <= (signed long)writeBuffer.offset); /* the offset is into the content, not the headers */ writeBuffer.offset += (_reply ? _reply->hdr_sz : 0); Index: squid3/src/store.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/store.cc,v retrieving revision 1.27.8.1 retrieving revision 1.27.8.2 diff -u -r1.27.8.1 -r1.27.8.2 --- squid3/src/store.cc 24 Aug 2005 22:50:29 -0000 1.27.8.1 +++ squid3/src/store.cc 25 Aug 2005 21:11:33 -0000 1.27.8.2 @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.27.8.1 2005/08/24 22:50:29 dwsquid Exp $ + * $Id: store.cc,v 1.27.8.2 2005/08/25 21:11:33 rousskov Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -826,7 +826,10 @@ StoreIOBuffer tempBuffer; tempBuffer.data = (char *)buf; tempBuffer.length = len; - tempBuffer.offset = mem->endOffset() - (e->getReply() ? e->getReply()->hdr_sz : 0); + + const int headers = e->getReply() ? e->getReply()->hdr_sz : 0; + assert(mem->endOffset() >= headers); + tempBuffer.offset = mem->endOffset() - headers; e->write(tempBuffer); }