Blame SOURCES/libxml2-Fix-parsing-short-unclosed-comment-uninitialized-access.patch

6dedca
From 466ef17b8cf8d68393f3a56cda8e7a5504aacf98 Mon Sep 17 00:00:00 2001
6dedca
From: Daniel Veillard <veillard@redhat.com>
6dedca
Date: Fri, 30 Oct 2015 21:14:55 +0800
6dedca
Subject: [PATCH] Fix parsing short unclosed comment uninitialized access
6dedca
To: libvir-list@redhat.com
6dedca
6dedca
For https://bugzilla.gnome.org/show_bug.cgi?id=746048
6dedca
The HTML parser was too optimistic when processing comments and
6dedca
didn't check for the end of the stream on the first 2 characters
6dedca
6dedca
Signed-off-by: Daniel Veillard <veillard@redhat.com>
6dedca
---
6dedca
 HTMLparser.c | 21 ++++++++++++++-------
6dedca
 1 file changed, 14 insertions(+), 7 deletions(-)
6dedca
6dedca
diff --git a/HTMLparser.c b/HTMLparser.c
6dedca
index dd0c1ea..cab499a 100644
6dedca
--- a/HTMLparser.c
6dedca
+++ b/HTMLparser.c
6dedca
@@ -3245,12 +3245,17 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
6dedca
 	ctxt->instate = state;
6dedca
 	return;
6dedca
     }
6dedca
+    len = 0;
6dedca
+    buf[len] = 0;
6dedca
     q = CUR_CHAR(ql);
6dedca
+    if (!IS_CHAR(q))
6dedca
+        goto unfinished;
6dedca
     NEXTL(ql);
6dedca
     r = CUR_CHAR(rl);
6dedca
+    if (!IS_CHAR(r))
6dedca
+        goto unfinished;
6dedca
     NEXTL(rl);
6dedca
     cur = CUR_CHAR(l);
6dedca
-    len = 0;
6dedca
     while (IS_CHAR(cur) &&
6dedca
            ((cur != '>') ||
6dedca
 	    (r != '-') || (q != '-'))) {
6dedca
@@ -3281,18 +3286,20 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
6dedca
 	}
6dedca
     }
6dedca
     buf[len] = 0;
6dedca
-    if (!IS_CHAR(cur)) {
6dedca
-	htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
6dedca
-	             "Comment not terminated \n
6dedca
-	xmlFree(buf);
6dedca
-    } else {
6dedca
+    if (IS_CHAR(cur)) {
6dedca
         NEXT;
6dedca
 	if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
6dedca
 	    (!ctxt->disableSAX))
6dedca
 	    ctxt->sax->comment(ctxt->userData, buf);
6dedca
 	xmlFree(buf);
6dedca
+	ctxt->instate = state;
6dedca
+	return;
6dedca
     }
6dedca
-    ctxt->instate = state;
6dedca
+
6dedca
+unfinished:
6dedca
+    htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
6dedca
+		 "Comment not terminated \n
6dedca
+    xmlFree(buf);
6dedca
 }
6dedca
 
6dedca
 /**
6dedca
-- 
6dedca
2.5.0
6dedca