------------------------------------------------------------ revno: 13993 revision-id: squid3@treenet.co.nz-20160223154710-wcrkwwyohp2f263g parent: squidadm@squid-cache.org-20160220001407-1ejhjctyaf86oame fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=3870 author: William Lima committer: Amos Jeffries branch nick: 3.5 timestamp: Wed 2016-02-24 04:47:10 +1300 message: Bug 3870: assertion failed: String.cc: 'len_ + len <65536' in ESI::CustomParser The custom ESI parser used in absence of libxml2 or libexpat parsers was restricted to handling 64KB buffers but under some conditions could expand to over 64KB during the parse process. Hitting this assertion. TODO: the parser can now be redesigned to make use of Tokenizer and CharacterSet parsing tools. But that is left for later work. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20160223154710-wcrkwwyohp2f263g # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: d8513f84eb3af6881e9264e9e4a4b0b3c6302caf # timestamp: 2016-02-23 15:50:48 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squidadm@squid-cache.org-20160220001407-\ # 1ejhjctyaf86oame # # Begin patch === modified file 'src/esi/CustomParser.cc' --- src/esi/CustomParser.cc 2016-01-01 00:14:27 +0000 +++ src/esi/CustomParser.cc 2016-02-23 15:47:10 +0000 @@ -89,9 +89,11 @@ } size_t openESITags (0); - //erring on the safe side. Probably rawBuf would be ok too - char const *currentPos = content.termedBuf(); - size_t remainingCount = content.size(); + // TODO: convert to Tokenizer parse + // erring on the safe side for now. Probably rawContent would be ok too + // note that operations below do *X='\0' ... altering the 'const' buffer content. + char const *currentPos = content.c_str(); + SBuf::size_type remainingCount = content.length(); char const *tag = NULL; while ((tag = findTag(currentPos, remainingCount))) { === modified file 'src/esi/CustomParser.h' --- src/esi/CustomParser.h 2016-01-01 00:14:27 +0000 +++ src/esi/CustomParser.h 2016-02-23 15:47:10 +0000 @@ -14,7 +14,7 @@ /* inherits from */ #include "esi/Parser.h" -/* for String variables */ +#include "SBuf.h" #include "SquidString.h" /** @@ -46,7 +46,7 @@ ESIParserClient *theClient; String error; /* cheap n dirty - buffer it all */ - String content; + SBuf content; /* TODO: make a class of this type code */ ESITAG_t lastTag; };