mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-26 00:37:43 +03:00
parser: Fix push parser with unterminated CDATA sections
Short-lived regression found by OSS-Fuzz.
This commit is contained in:
20
parser.c
20
parser.c
@@ -11794,20 +11794,24 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
*/
|
*/
|
||||||
term = BAD_CAST strstr((const char *) ctxt->input->cur,
|
term = BAD_CAST strstr((const char *) ctxt->input->cur,
|
||||||
"]]>");
|
"]]>");
|
||||||
if (term == NULL)
|
|
||||||
term = ctxt->input->end;
|
|
||||||
} else {
|
} else {
|
||||||
term = xmlParseLookupString(ctxt, 0, "]]>", 3);
|
term = xmlParseLookupString(ctxt, 0, "]]>", 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (term == NULL) {
|
if (term == NULL) {
|
||||||
int tmp;
|
int tmp, size;
|
||||||
|
|
||||||
if (avail < XML_PARSER_BIG_BUFFER_SIZE + 2)
|
if (terminate) {
|
||||||
goto done;
|
/* Unfinished CDATA section */
|
||||||
ctxt->checkIndex = 0;
|
size = ctxt->input->end - ctxt->input->cur;
|
||||||
tmp = xmlCheckCdataPush(ctxt->input->cur,
|
} else {
|
||||||
XML_PARSER_BIG_BUFFER_SIZE, 0);
|
if (avail < XML_PARSER_BIG_BUFFER_SIZE + 2)
|
||||||
|
goto done;
|
||||||
|
ctxt->checkIndex = 0;
|
||||||
|
/* XXX: Why don't we pass the full buffer? */
|
||||||
|
size = XML_PARSER_BIG_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
tmp = xmlCheckCdataPush(ctxt->input->cur, size, 0);
|
||||||
if (tmp < 0) {
|
if (tmp < 0) {
|
||||||
tmp = -tmp;
|
tmp = -tmp;
|
||||||
ctxt->input->cur += tmp;
|
ctxt->input->cur += tmp;
|
||||||
|
|||||||
Reference in New Issue
Block a user