xzyang / rpms / libxml2

Forked from rpms/libxml2 3 years ago
Clone

Blame SOURCES/libxml2-Detect-incoherency-on-GROW.patch

267d54
From dfc5aae623e97336323e59a94450f1a708eb7c0c Mon Sep 17 00:00:00 2001
267d54
From: Daniel Veillard <veillard@redhat.com>
267d54
Date: Fri, 20 Nov 2015 15:04:09 +0800
267d54
Subject: [PATCH] Detect incoherency on GROW
267d54
To: libvir-list@redhat.com
267d54
267d54
the current pointer to the input has to be between the base and end
267d54
if not stop everything we have an internal state error.
267d54
267d54
Signed-off-by: Daniel Veillard <veillard@redhat.com>
267d54
---
267d54
 parser.c | 9 ++++++++-
267d54
 1 file changed, 8 insertions(+), 1 deletion(-)
267d54
267d54
diff --git a/parser.c b/parser.c
267d54
index 9aed98d..7602498 100644
267d54
--- a/parser.c
267d54
+++ b/parser.c
267d54
@@ -2072,9 +2072,16 @@ static void xmlGROW (xmlParserCtxtPtr ctxt) {
267d54
          ((ctxt->input->buf) && (ctxt->input->buf->readcallback != (xmlInputReadCallback) xmlNop)) &&
267d54
         ((ctxt->options & XML_PARSE_HUGE) == 0)) {
267d54
         xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
267d54
-        ctxt->instate = XML_PARSER_EOF;
267d54
+        xmlHaltParser(ctxt);
267d54
+	return;
267d54
     }
267d54
     xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
267d54
+    if ((ctxt->input->cur > ctxt->input->end) ||
267d54
+        (ctxt->input->cur < ctxt->input->base)) {
267d54
+        xmlHaltParser(ctxt);
267d54
+        xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "cur index out of bound");
267d54
+	return;
267d54
+    }
267d54
     if ((ctxt->input->cur != NULL) && (*ctxt->input->cur == 0) &&
267d54
         (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
267d54
 	    xmlPopInput(ctxt);
267d54
-- 
267d54
2.5.0
267d54