xzyang / rpms / libxml2

Forked from rpms/libxml2 3 years ago
Clone

Blame SOURCES/libxml2-Heap-based-buffer-underreads-due-to-xmlParseName.patch

6dedca
From 7d23a33fbf8fe09fe52f9abafeafb9f438229603 Mon Sep 17 00:00:00 2001
6dedca
From: David Kilzer <ddkilzer@apple.com>
6dedca
Date: Tue, 26 Jan 2016 16:57:03 -0800
6dedca
Subject: [PATCH] Heap-based buffer-underreads due to xmlParseName
6dedca
To: libvir-list@redhat.com
6dedca
6dedca
For https://bugzilla.gnome.org/show_bug.cgi?id=759573
6dedca
6dedca
* parser.c:
6dedca
(xmlParseElementDecl): Return early on invalid input to fix
6dedca
non-minimized test case (759573-2.xml).  Otherwise the parser
6dedca
gets into a bad state in SKIP(3) at the end of the function.
6dedca
(xmlParseConditionalSections): Halt parsing when hitting invalid
6dedca
input that would otherwise caused xmlParserHandlePEReference()
6dedca
to recurse unexpectedly.  This fixes the minimized test case
6dedca
(759573.xml).
6dedca
6dedca
* result/errors/759573-2.xml: Add.
6dedca
* result/errors/759573-2.xml.err: Add.
6dedca
* result/errors/759573-2.xml.str: Add.
6dedca
* result/errors/759573.xml: Add.
6dedca
* result/errors/759573.xml.err: Add.
6dedca
* result/errors/759573.xml.str: Add.
6dedca
* test/errors/759573-2.xml: Add.
6dedca
* test/errors/759573.xml: Add.
6dedca
6dedca
Had to fixup by removing test 759573-2
6dedca
6dedca
Signed-off-by: Daniel Veillard <veillard@redhat.com>
6dedca
---
6dedca
 parser.c                     |  2 ++
6dedca
 result/errors/759573.xml     |  0
6dedca
 result/errors/759573.xml.err | 31 +++++++++++++++++++++++++++++++
6dedca
 result/errors/759573.xml.str |  4 ++++
6dedca
 test/errors/759573.xml       |  1 +
6dedca
 5 files changed, 38 insertions(+)
6dedca
 create mode 100644 result/errors/759573.xml
6dedca
 create mode 100644 result/errors/759573.xml.err
6dedca
 create mode 100644 result/errors/759573.xml.str
6dedca
 create mode 100644 test/errors/759573.xml
6dedca
6dedca
diff --git a/parser.c b/parser.c
6dedca
index 133df95..0accf54 100644
6dedca
--- a/parser.c
6dedca
+++ b/parser.c
6dedca
@@ -6683,6 +6683,7 @@ xmlParseElementDecl(xmlParserCtxtPtr ctxt) {
6dedca
 	if (!IS_BLANK_CH(CUR)) {
6dedca
 	    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6dedca
 		           "Space required after 'ELEMENT'\n");
6dedca
+	    return(-1);
6dedca
 	}
6dedca
         SKIP_BLANKS;
6dedca
         name = xmlParseName(ctxt);
6dedca
@@ -6834,6 +6835,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
6dedca
 
6dedca
 	    if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
6dedca
 		xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
6dedca
+		xmlHaltParser(ctxt);
6dedca
 		break;
6dedca
 	    }
6dedca
 	}
6dedca
diff --git a/result/errors/759573.xml.err b/result/errors/759573.xml.err
6dedca
new file mode 100644
6dedca
index 0000000..2c21e9a
6dedca
--- /dev/null
6dedca
+++ b/result/errors/759573.xml.err
6dedca
@@ -0,0 +1,31 @@
6dedca
+./test/errors/759573.xml:1: parser error : Space required after '
6dedca
+ELEMENT t (A)>
6dedca
+                                                                               ^
6dedca
+./test/errors/759573.xml:1: parser error : Space required after the entity name
6dedca
+LEMENT t (A)>
6dedca
+                                                                               ^
6dedca
+./test/errors/759573.xml:1: parser error : Entity value required
6dedca
+LEMENT t (A)>
6dedca
+                                                                               ^
6dedca
+Entity: line 1: parser error : PEReference: no name
6dedca
+ %xx; 
6dedca
+     ^
6dedca
+Entity: line 1: 
6dedca
+%
6dedca
+ ^
6dedca
+Entity: line 1: parser error : Content error in the external subset
6dedca
+ %xx; 
6dedca
+     ^
6dedca
+Entity: line 1: 
6dedca
+%
6dedca
+            ^
6dedca
+./test/errors/759573.xml:1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
6dedca
+
6dedca
+T t (A)>%xx;
6dedca
+                                                                               ^
6dedca
+./test/errors/759573.xml:1: parser error : DOCTYPE improperly terminated
6dedca
+T t (A)>%xx;
6dedca
+                                                                               ^
6dedca
+./test/errors/759573.xml:1: parser error : Start tag expected, '<' not found
6dedca
+T t (A)>%xx;
6dedca
+                                                                               ^
6dedca
diff --git a/result/errors/759573.xml.str b/result/errors/759573.xml.str
6dedca
new file mode 100644
6dedca
index 0000000..1b6addb
6dedca
--- /dev/null
6dedca
+++ b/result/errors/759573.xml.str
6dedca
@@ -0,0 +1,4 @@
6dedca
+./test/errors/759573.xml:1: parser error : Extra content at the end of the document
6dedca
+
6dedca
+               ^
6dedca
+./test/errors/759573.xml : failed to parse
6dedca
diff --git a/test/errors/759573.xml b/test/errors/759573.xml
6dedca
new file mode 100644
6dedca
index 0000000..69ebb57
6dedca
--- /dev/null
6dedca
+++ b/test/errors/759573.xml
6dedca
@@ -0,0 +1 @@
6dedca
+%xx;
6dedca
\ No newline at end of file
6dedca
-- 
6dedca
2.5.5
6dedca