From a781ee3395ad715c6383842463d412591a63e117 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 21 Nov 2022 20:10:42 +0100 Subject: [PATCH] Revert "parser: Add overflow checks to xmlParseLookup functions" This reverts commit bfc55d688427972d093be010a8c2ef265375fcb2. It's better to fix the root cause. --- parser.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/parser.c b/parser.c index 3b64c434..cc82b6e3 100644 --- a/parser.c +++ b/parser.c @@ -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;