]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3870: assertion failed: String.cc: 'len_ + len <65536' in ESI::CustomParser
authorWilliam Lima <william.lima@hscbrasil.com.br>
Thu, 18 Feb 2016 12:48:08 +0000 (01:48 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 18 Feb 2016 12:48:08 +0000 (01:48 +1300)
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.

src/esi/CustomParser.cc
src/esi/CustomParser.h

index 84a5cd9af5c3f35699d1d87bc002e5d638e111f8..9bfe03bb296eae22c0ec2e8df56c38a7463d5067 100644 (file)
@@ -89,9 +89,11 @@ ESICustomParser::parse(char const *dataToParse, size_t const lengthOfData, bool
     }
 
     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))) {
index 7a060b4e0de4f88ba7d88a1bb42a3b3e5e38e7d3..565fbaa790be6bfb1277f4264416609df6493ee8 100644 (file)
@@ -14,7 +14,7 @@ class Trie;
 /* inherits from */
 #include "esi/Parser.h"
 
-/* for String variables */
+#include "SBuf.h"
 #include "SquidString.h"
 
 /**
@@ -46,7 +46,7 @@ private:
     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;
 };