xzyang / rpms / libxml2

Forked from rpms/libxml2 3 years ago
Clone

Blame SOURCES/libxml2-Fail-parsing-early-on-if-encoding-conversion-failed.patch

267d54
From c171a25d614097e53ab84f64639de4dfbc197613 Mon Sep 17 00:00:00 2001
267d54
From: Daniel Veillard <veillard@redhat.com>
267d54
Date: Mon, 29 Jun 2015 16:10:26 +0800
267d54
Subject: [PATCH] Fail parsing early on if encoding conversion failed
267d54
To: libvir-list@redhat.com
267d54
267d54
For https://bugzilla.gnome.org/show_bug.cgi?id=751631
267d54
267d54
If we fail conversing the current input stream while
267d54
processing the encoding declaration of the XMLDecl
267d54
then it's safer to just abort there and not try to
267d54
report further errors.
267d54
267d54
Signed-off-by: Daniel Veillard <veillard@redhat.com>
267d54
---
267d54
 parser.c | 6 +++++-
267d54
 1 file changed, 5 insertions(+), 1 deletion(-)
267d54
267d54
diff --git a/parser.c b/parser.c
267d54
index dc14e5c..e2e0ad8 100644
267d54
--- a/parser.c
267d54
+++ b/parser.c
267d54
@@ -10415,7 +10415,11 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
267d54
 
267d54
             handler = xmlFindCharEncodingHandler((const char *) encoding);
267d54
 	    if (handler != NULL) {
267d54
-		xmlSwitchToEncoding(ctxt, handler);
267d54
+		if (xmlSwitchToEncoding(ctxt, handler) < 0) {
267d54
+		    /* failed to convert */
267d54
+		    ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING;
267d54
+		    return(NULL);
267d54
+		}
267d54
 	    } else {
267d54
 		xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
267d54
 			"Unsupported encoding %s\n", encoding);
267d54
-- 
267d54
2.5.0
267d54