[libxml2] Make sure to grow input buffer in xmlParseMisc



commit 96535657651b3a5a92a53c9d32d07ee039ad1767
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Mon Feb 7 15:26:33 2022 +0100

    Make sure to grow input buffer in xmlParseMisc
    
    Otherwise, large amount of whitespace could lead to documents not
    being parsed correctly.
    
    Fixes #299.

 parser.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/parser.c b/parser.c
index 7796cb51..d923b8ee 100644
--- a/parser.c
+++ b/parser.c
@@ -10659,16 +10659,16 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
 
 void
 xmlParseMisc(xmlParserCtxtPtr ctxt) {
-    while ((ctxt->instate != XML_PARSER_EOF) &&
-           (((RAW == '<') && (NXT(1) == '?')) ||
-            (CMP4(CUR_PTR, '<', '!', '-', '-')) ||
-            IS_BLANK_CH(CUR))) {
+    while (ctxt->instate != XML_PARSER_EOF) {
+        SKIP_BLANKS;
+        GROW;
         if ((RAW == '<') && (NXT(1) == '?')) {
            xmlParsePI(ctxt);
-       } else if (IS_BLANK_CH(CUR)) {
-           NEXT;
-       } else
+        } else if (CMP4(CUR_PTR, '<', '!', '-', '-')) {
            xmlParseComment(ctxt);
+        } else {
+            break;
+        }
     }
 }
 
@@ -10774,7 +10774,6 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
     /*
      * The Misc part of the Prolog
      */
-    GROW;
     xmlParseMisc(ctxt);
 
     /*


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