1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-09 04:58:16 +03:00

Revert "parser: Add overflow checks to xmlParseLookup functions"

This reverts commit bfc55d688427972d093be010a8c2ef265375fcb2.

It's better to fix the root cause.
This commit is contained in:
Nick Wellnhofer 2022-11-21 20:10:42 +01:00
parent bfc55d6884
commit a781ee3395

View File

@ -11083,17 +11083,14 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
static int
xmlParseLookupChar(xmlParserCtxtPtr ctxt, int c) {
const xmlChar *cur;
const xmlChar *end = ctxt->input->end;
if (ctxt->checkIndex == 0) {
cur = ctxt->input->cur + 1;
} else {
cur = ctxt->input->cur + ctxt->checkIndex;
}
if (cur >= end)
return(0);
if (memchr(cur, c, end - cur) == NULL) {
if (memchr(cur, c, ctxt->input->end - cur) == NULL) {
ctxt->checkIndex = ctxt->input->end - ctxt->input->cur;
return(0);
} else {
@ -11115,18 +11112,17 @@ static const xmlChar *
xmlParseLookupString(xmlParserCtxtPtr ctxt, size_t startDelta,
const char *str, size_t strLen) {
const xmlChar *cur, *term;
const xmlChar *end = ctxt->input->end;
if (ctxt->checkIndex == 0) {
cur = ctxt->input->cur + startDelta;
} else {
cur = ctxt->input->cur + ctxt->checkIndex;
}
if (cur >= end)
return(0);
term = BAD_CAST strstr((const char *) cur, str);
if (term == NULL) {
const xmlChar *end = ctxt->input->end;
/* Rescan (strLen - 1) characters. */
if ((size_t) (end - cur) < strLen)
end = cur;