From: Timo Sirainen Date: Tue, 16 Aug 2011 15:50:42 +0000 (+0300) Subject: fts: Assert-crashfix to HTML parsing if the document ends with a small tag. X-Git-Tag: 2.1.alpha1~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b37dc96b11bc703e3cda1a71c0a0f735b4f2a4f2;p=thirdparty%2Fdovecot%2Fcore.git fts: Assert-crashfix to HTML parsing if the document ends with a small tag. --- diff --git a/src/plugins/fts/fts-parser-html.c b/src/plugins/fts/fts-parser-html.c index 470c15b1ef..6c1faefc2e 100644 --- a/src/plugins/fts/fts-parser-html.c +++ b/src/plugins/fts/fts-parser-html.c @@ -64,7 +64,7 @@ static bool parse_tag_name(struct html_fts_parser *parser, const unsigned char *data, size_t size) { - size_t i = 1; + size_t i; if (size >= 3 && memcmp(data, "!--", 3) == 0) { parser->state = HTML_STATE_COMMENT; @@ -75,10 +75,18 @@ parse_tag_name(struct html_fts_parser *parser, i = 5; } else if (size > 6 && i_memcasecmp(data, "script", 6) == 0) { i = 6; - } else if (size <= 6) { - /* need more data */ - return 0; } else { + if (size <= 6) { + /* can we see the whole tag name? */ + for (i = 0; i < size; i++) { + if (HTML_WHITESPACE(data[i]) || data[i] == '>') + break; + } + if (i == size) { + /* need more data */ + return 0; + } + } parser->state = HTML_STATE_TAG; return 1; }