xzyang / rpms / libxml2

Forked from rpms/libxml2 3 years ago
Clone

Blame SOURCES/libxml2-Do-not-fetch-external-parameter-entities.patch

6dedca
commit 84b04b03bd6d31316fd5f0ad1c9cd31952671998
6dedca
Author: Daniel Veillard <veillard@redhat.com>
6dedca
Date:   Tue Apr 22 15:30:56 2014 +0800
6dedca
6dedca
    Do not fetch external parameter entities
6dedca
    
6dedca
    Unless explicitely asked for when validating or replacing entities
6dedca
    with their value. Problem pointed out by Daniel Berrange <berrange@redhat.com>
6dedca
6dedca
diff --git a/parser.c b/parser.c
6dedca
index 3c72cbb..32f1475 100644
6dedca
--- a/parser.c
6dedca
+++ b/parser.c
6dedca
@@ -2622,6 +2622,20 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
6dedca
 		    xmlCharEncoding enc;
6dedca
 
6dedca
 		    /*
6dedca
+		     * Note: external parsed entities will not be loaded, it is
6dedca
+		     * not required for a non-validating parser, unless the
6dedca
+		     * option of validating, or substituting entities were
6dedca
+		     * given. Doing so is far more secure as the parser will
6dedca
+		     * only process data coming from the document entity by
6dedca
+		     * default.
6dedca
+		     */
6dedca
+                    if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
6dedca
+		        ((ctxt->options & XML_PARSE_NOENT) == 0) &&
6dedca
+			((ctxt->options & XML_PARSE_DTDVALID) == 0) &&
6dedca
+			(ctxt->validate == 0))
6dedca
+			return;
6dedca
+
6dedca
+		    /*
6dedca
 		     * handle the extra spaces added before and after
6dedca
 		     * c.f. http://www.w3.org/TR/REC-xml#as-PE
6dedca
 		     * this is done independently.