|
|
1c8959 |
From be24335cbc0019894e6222bd817e717c41550c3c Mon Sep 17 00:00:00 2001
|
|
|
1c8959 |
From: Daniel Veillard <veillard@redhat.com>
|
|
|
1c8959 |
Date: Mon, 14 Mar 2016 17:19:44 +0800
|
|
|
1c8959 |
Subject: [PATCH] Fix inappropriate fetch of entities content
|
|
|
1c8959 |
To: libvir-list@redhat.com
|
|
|
1c8959 |
|
|
|
1c8959 |
For https://bugzilla.gnome.org/show_bug.cgi?id=761430
|
|
|
1c8959 |
|
|
|
1c8959 |
libfuzzer regression testing exposed another case where the parser would
|
|
|
1c8959 |
fetch content of an external entity while not in validating mode.
|
|
|
1c8959 |
Plug that hole
|
|
|
1c8959 |
|
|
|
1c8959 |
Signed-off-by: Daniel Veillard <veillard@redhat.com>
|
|
|
1c8959 |
---
|
|
|
1c8959 |
parser.c | 16 +++++++++++++++-
|
|
|
1c8959 |
1 file changed, 15 insertions(+), 1 deletion(-)
|
|
|
1c8959 |
|
|
|
1c8959 |
diff --git a/parser.c b/parser.c
|
|
|
1c8959 |
index 46ab0e8..1936599 100644
|
|
|
1c8959 |
--- a/parser.c
|
|
|
1c8959 |
+++ b/parser.c
|
|
|
1c8959 |
@@ -2854,7 +2854,21 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
|
|
|
1c8959 |
ctxt->nbentities += ent->checked / 2;
|
|
|
1c8959 |
if (ent != NULL) {
|
|
|
1c8959 |
if (ent->content == NULL) {
|
|
|
1c8959 |
- xmlLoadEntityContent(ctxt, ent);
|
|
|
1c8959 |
+ /*
|
|
|
1c8959 |
+ * Note: external parsed entities will not be loaded,
|
|
|
1c8959 |
+ * it is not required for a non-validating parser to
|
|
|
1c8959 |
+ * complete external PEreferences coming from the
|
|
|
1c8959 |
+ * internal subset
|
|
|
1c8959 |
+ */
|
|
|
1c8959 |
+ if (((ctxt->options & XML_PARSE_NOENT) != 0) ||
|
|
|
1c8959 |
+ ((ctxt->options & XML_PARSE_DTDVALID) != 0) ||
|
|
|
1c8959 |
+ (ctxt->validate != 0)) {
|
|
|
1c8959 |
+ xmlLoadEntityContent(ctxt, ent);
|
|
|
1c8959 |
+ } else {
|
|
|
1c8959 |
+ xmlWarningMsg(ctxt, XML_ERR_ENTITY_PROCESSING,
|
|
|
1c8959 |
+ "not validating will not read content for PE entity %s\n",
|
|
|
1c8959 |
+ ent->name, NULL);
|
|
|
1c8959 |
+ }
|
|
|
1c8959 |
}
|
|
|
1c8959 |
ctxt->depth++;
|
|
|
1c8959 |
rep = xmlStringDecodeEntities(ctxt, ent->content, what,
|
|
|
1c8959 |
--
|
|
|
1c8959 |
2.5.5
|
|
|
1c8959 |
|