From 01b54d65f1bc32538314f01cbe89d89b2d0baa77 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 6 Feb 2010 20:21:26 -0500 Subject: [PATCH] Relax libxml limits when parsing label files Glabels bug #2940758. Back port from master: Use XML_PARSE_HUGE parser option so that we can handle large text nodes, such as encoded images. This modification is only applied if libxml 2.7+ is available, as to not introduce new dependencies. --- configure.in | 9 +++++++++ src/Makefile.am | 1 + src/xml-label.c | 10 +++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 12c9cd34..1d11adc8 100644 --- a/configure.in +++ b/configure.in @@ -129,6 +129,15 @@ AC_SUBST(MYGAL_CFLAGS) AC_SUBST(MYGAL_LIBS) +dnl --------------------------------------------------------------------------- +dnl - Is XML_PARSE_HUGE available? +dnl --------------------------------------------------------------------------- +PKG_CHECK_MODULES(XML_PARSE_HUGE, libxml-2.0 >= 2.7.0, + HAVE_XML_PARSE_HUGE="-DHAVE_XML_PARSE_HUGE", + HAVE_XML_PARSE_HUGE="-UHAVE_XML_PARSE_HUGE") +AC_SUBST(HAVE_XML_PARSE_HUGE) + + dnl --------------------------------------------------------------------------- dnl - Enable deprecation testing dnl --------------------------------------------------------------------------- diff --git a/src/Makefile.am b/src/Makefile.am index d687e1ba..aea24826 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,7 @@ INCLUDES = \ -I$(LIB_BARCODE_DIR) \ -I$(LIB_IEC16022_DIR) \ $(GLABELS_CFLAGS) \ + $(HAVE_XML_PARSE_HUGE) \ $(DISABLE_DEPRECATED_CFLAGS) \ -DPREFIX=\""$(prefix)"\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ diff --git a/src/xml-label.c b/src/xml-label.c index 5a56d8cd..07452b25 100644 --- a/src/xml-label.c +++ b/src/xml-label.c @@ -184,7 +184,11 @@ gl_xml_label_open (const gchar *utf8_filename, filename = g_filename_from_utf8 (utf8_filename, -1, NULL, NULL, NULL); g_return_val_if_fail (filename, NULL); +#ifndef HAVE_XML_PARSE_HUGE doc = xmlParseFile (filename); +#else + doc = xmlReadFile (filename, NULL, XML_PARSE_HUGE); +#endif if (!doc) { g_message (_("xmlParseFile error")); *status = XML_LABEL_ERROR_OPEN_PARSE; @@ -221,9 +225,13 @@ gl_xml_label_open_buffer (const gchar *buffer, gl_debug (DEBUG_XML, "START"); +#ifndef HAVE_XML_PARSE_HUGE doc = xmlParseDoc ((xmlChar *) buffer); +#else + doc = xmlReadDoc ((xmlChar *) buffer, NULL, NULL, XML_PARSE_HUGE); +#endif if (!doc) { - g_message (_("xmlParseFile error")); + g_message (_("xmlParseDoc error")); *status = XML_LABEL_ERROR_OPEN_PARSE; return NULL; } -- 2.39.5