xzyang / rpms / libxml2

Forked from rpms/libxml2 3 years ago
Clone

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

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