[libxml2] Fix xmlHaltParser



commit 24246c762693c7237b0baaba85111a0326efa867
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Tue Jun 20 12:56:36 2017 +0200

    Fix xmlHaltParser
    
    Pop all extra input streams before resetting the input. Otherwise,
    a call to xmlPopInput could make input available again.
    
    Also set input->end to input->cur.
    
    Changes the test output for some error tests. Unfortunately, some
    fuzzed test cases were added to the test suite without manual cleanup.
    This makes it almost impossible to review the impact of later changes
    on the test output.

 parser.c                       |    3 +++
 result/errors/759573-2.xml.err |   12 ++++++------
 result/errors/759573.xml.err   |   17 ++++++++++-------
 3 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/parser.c b/parser.c
index 3e67abf..2bad113 100644
--- a/parser.c
+++ b/parser.c
@@ -12590,6 +12590,8 @@ xmlHaltParser(xmlParserCtxtPtr ctxt) {
         return;
     ctxt->instate = XML_PARSER_EOF;
     ctxt->disableSAX = 1;
+    while (ctxt->inputNr > 1)
+        xmlFreeInputStream(inputPop(ctxt));
     if (ctxt->input != NULL) {
         /*
         * in case there was a specific allocation deallocate before
@@ -12601,6 +12603,7 @@ xmlHaltParser(xmlParserCtxtPtr ctxt) {
        }
        ctxt->input->cur = BAD_CAST"";
        ctxt->input->base = ctxt->input->cur;
+        ctxt->input->end = ctxt->input->cur;
     }
 }
 
diff --git a/result/errors/759573-2.xml.err b/result/errors/759573-2.xml.err
index d8773d8..0551c9e 100644
--- a/result/errors/759573-2.xml.err
+++ b/result/errors/759573-2.xml.err
@@ -48,11 +48,11 @@ Entity: line 3:
              ^
 ./test/errors/759573-2.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in 
Markup declaration
 
-%xx;�ggKENSMYNT&#35;MENTD&#372zz;'>
-    ^
+
+^
 ./test/errors/759573-2.xml:6: parser error : DOCTYPE improperly terminated
-%xx;�ggKENSMYNT&#35;MENTD&#372zz;'>
-    ^
+
+^
 ./test/errors/759573-2.xml:6: parser error : Start tag expected, '<' not found
-%xx;�ggKENSMYNT&#35;MENTD&#372zz;'>
-    ^
+
+^
diff --git a/result/errors/759573.xml.err b/result/errors/759573.xml.err
index 2c21e9a..65e42c7 100644
--- a/result/errors/759573.xml.err
+++ b/result/errors/759573.xml.err
@@ -21,11 +21,14 @@ Entity: line 1:
             ^
 ./test/errors/759573.xml:1: parser error : internal error: xmlParseInternalSubset: error detected in Markup 
declaration
 
-T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
-                                                                               ^
+<?h?><!DOCTYPEt[<!ELEMENT t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;00
+     ^
 ./test/errors/759573.xml:1: parser error : DOCTYPE improperly terminated
-T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
-                                                                               ^
-./test/errors/759573.xml:1: parser error : Start tag expected, '<' not found
-T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
-                                                                               ^
+<?h?><!DOCTYPEt[<!ELEMENT t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;00
+     ^
+./test/errors/759573.xml:1: parser error : StartTag: invalid element name
+<?h?><!DOCTYPEt[<!ELEMENT t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;00
+      ^
+./test/errors/759573.xml:1: parser error : Extra content at the end of the document
+<?h?><!DOCTYPEt[<!ELEMENT t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;00
+      ^


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]