diff options
author | Joey Arhar <jarhar@chromium.org> | 2021-05-25 14:27:54 +0000 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2022-04-14 06:19:40 +0000 |
commit | 846b4dc93a6f31bc44e81a7561f62e79ecde49bb (patch) | |
tree | 77355687694e2886d5a7f4a2185f4f99c99d4339 | |
parent | d95b7fa6c66aad4e2e35c1f872c9b1069ab81be4 (diff) | |
download | qtwebengine-chromium-846b4dc93a6f31bc44e81a7561f62e79ecde49bb.tar.gz |
[Backport] Roll libxml from bfd2f430 to a46e85f6
2021-05-22 rickert@fortiss.org Update CMake project version
2021-05-22 rickert@fortiss.org Add CMake alias targets for embedded projects
2021-05-18 dking@redhat.com Fix some validation errors in the FAQ
2021-05-19 dking@redhat.com Remove unused variable in xmlCharEncOutFunc
2021-05-16 rickert@fortiss.org Add missing file xmlwin32version.h.in to EXTRA_DIST
2021-05-16 rickert@fortiss.org Add instructions on how to use CMake to compile libxml
2021-05-18 wellnhofer@aevum.de Work around lxml API abuse
2021-05-20 mike.dalessio@gmail.com fix: avoid segfault at exit when using custom memory functions
2021-05-13 veillard@redhat.com Release of libxml2-2.9.12
2021-05-13 veillard@redhat.com Release of libxml2-2.9.11
2021-05-13 veillard@redhat.com Patch for security issue CVE-2021-3541
Backport review link:
https://chromium-review.googlesource.com/c/chromium/src/+/2915101
Bug: 934413
Change-Id: I5b37109c0043fe16730b91d0eb032332b615c33a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r-- | chromium/third_party/libxml/README.chromium | 4 | ||||
-rw-r--r-- | chromium/third_party/libxml/linux/config.h | 6 | ||||
-rw-r--r-- | chromium/third_party/libxml/linux/include/libxml/xmlversion.h | 8 | ||||
-rwxr-xr-x | chromium/third_party/libxml/linux/xml2-config | 2 | ||||
-rw-r--r-- | chromium/third_party/libxml/mac/config.h | 6 | ||||
-rw-r--r-- | chromium/third_party/libxml/mac/include/libxml/xmlversion.h | 8 | ||||
-rw-r--r-- | chromium/third_party/libxml/src/CMakeLists.txt | 4 | ||||
-rw-r--r-- | chromium/third_party/libxml/src/HTMLtree.c | 46 | ||||
-rw-r--r-- | chromium/third_party/libxml/src/configure.ac | 2 | ||||
-rw-r--r-- | chromium/third_party/libxml/src/encoding.c | 3 | ||||
-rw-r--r-- | chromium/third_party/libxml/src/include/libxml/Makefile.am | 2 | ||||
-rw-r--r-- | chromium/third_party/libxml/src/libxml2.spec | 6 | ||||
-rw-r--r-- | chromium/third_party/libxml/src/parser.c | 3 | ||||
-rw-r--r-- | chromium/third_party/libxml/src/testapi.c | 56 | ||||
-rw-r--r-- | chromium/third_party/libxml/src/xmlsave.c | 31 | ||||
-rw-r--r-- | chromium/third_party/libxml/win32/include/libxml/xmlversion.h | 8 |
16 files changed, 122 insertions, 73 deletions
diff --git a/chromium/third_party/libxml/README.chromium b/chromium/third_party/libxml/README.chromium index df76eb4a7ac..73f68bed4e3 100644 --- a/chromium/third_party/libxml/README.chromium +++ b/chromium/third_party/libxml/README.chromium @@ -1,7 +1,7 @@ Name: libxml URL: http://xmlsoft.org -Version: bfd2f4300fb348a0fb8265a17546a0eb8bdec719 -CPEPrefix: cpe:/a:xmlsoft:libxml2:2.9.9 +Version: a46e85f6698af712dc8bee683431c70d35e456ff +CPEPrefix: cpe:/a:xmlsoft:libxml2:2.9.12 License: MIT License File: src/Copyright Security Critical: yes diff --git a/chromium/third_party/libxml/linux/config.h b/chromium/third_party/libxml/linux/config.h index b6ae433ef39..25172b55031 100644 --- a/chromium/third_party/libxml/linux/config.h +++ b/chromium/third_party/libxml/linux/config.h @@ -249,7 +249,7 @@ #define PACKAGE_NAME "libxml2" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libxml2 2.9.10" +#define PACKAGE_STRING "libxml2 2.9.12" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "libxml2" @@ -258,7 +258,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "2.9.10" +#define PACKAGE_VERSION "2.9.12" /* Type cast for the send() function 2nd arg */ #define SEND_ARG2_CAST /**/ @@ -273,7 +273,7 @@ #define VA_LIST_IS_ARRAY 1 /* Version number of package */ -#define VERSION "2.9.10" +#define VERSION "2.9.12" /* Determine what socket length (socklen_t) data type is */ #define XML_SOCKLEN_T socklen_t diff --git a/chromium/third_party/libxml/linux/include/libxml/xmlversion.h b/chromium/third_party/libxml/linux/include/libxml/xmlversion.h index 37f673e252f..4c364e64044 100644 --- a/chromium/third_party/libxml/linux/include/libxml/xmlversion.h +++ b/chromium/third_party/libxml/linux/include/libxml/xmlversion.h @@ -29,21 +29,21 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version); * * the version string like "1.2.3" */ -#define LIBXML_DOTTED_VERSION "2.9.10" +#define LIBXML_DOTTED_VERSION "2.9.12" /** * LIBXML_VERSION: * * the version number: 1.2.3 value is 10203 */ -#define LIBXML_VERSION 20910 +#define LIBXML_VERSION 20912 /** * LIBXML_VERSION_STRING: * * the version number string, 1.2.3 value is "10203" */ -#define LIBXML_VERSION_STRING "20910" +#define LIBXML_VERSION_STRING "20912" /** * LIBXML_VERSION_EXTRA: @@ -58,7 +58,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version); * Macro to check that the libxml version in use is compatible with * the version the software has been compiled against */ -#define LIBXML_TEST_VERSION xmlCheckVersion(20910); +#define LIBXML_TEST_VERSION xmlCheckVersion(20912); #ifndef VMS #if 0 diff --git a/chromium/third_party/libxml/linux/xml2-config b/chromium/third_party/libxml/linux/xml2-config index 7a271d4ec7f..3717ff94744 100755 --- a/chromium/third_party/libxml/linux/xml2-config +++ b/chromium/third_party/libxml/linux/xml2-config @@ -58,7 +58,7 @@ while test $# -gt 0; do ;; --version) - echo 2.9.10 + echo 2.9.12 exit 0 ;; diff --git a/chromium/third_party/libxml/mac/config.h b/chromium/third_party/libxml/mac/config.h index ac184956426..27a79ec1716 100644 --- a/chromium/third_party/libxml/mac/config.h +++ b/chromium/third_party/libxml/mac/config.h @@ -249,7 +249,7 @@ #define PACKAGE_NAME "libxml2" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libxml2 2.9.10" +#define PACKAGE_STRING "libxml2 2.9.12" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "libxml2" @@ -258,7 +258,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "2.9.10" +#define PACKAGE_VERSION "2.9.12" /* Type cast for the send() function 2nd arg */ #define SEND_ARG2_CAST /**/ @@ -275,7 +275,7 @@ #define VA_LIST_IS_ARRAY 1 /* Version number of package */ -#define VERSION "2.9.10" +#define VERSION "2.9.12" /* Determine what socket length (socklen_t) data type is */ #define XML_SOCKLEN_T socklen_t diff --git a/chromium/third_party/libxml/mac/include/libxml/xmlversion.h b/chromium/third_party/libxml/mac/include/libxml/xmlversion.h index 37f673e252f..4c364e64044 100644 --- a/chromium/third_party/libxml/mac/include/libxml/xmlversion.h +++ b/chromium/third_party/libxml/mac/include/libxml/xmlversion.h @@ -29,21 +29,21 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version); * * the version string like "1.2.3" */ -#define LIBXML_DOTTED_VERSION "2.9.10" +#define LIBXML_DOTTED_VERSION "2.9.12" /** * LIBXML_VERSION: * * the version number: 1.2.3 value is 10203 */ -#define LIBXML_VERSION 20910 +#define LIBXML_VERSION 20912 /** * LIBXML_VERSION_STRING: * * the version number string, 1.2.3 value is "10203" */ -#define LIBXML_VERSION_STRING "20910" +#define LIBXML_VERSION_STRING "20912" /** * LIBXML_VERSION_EXTRA: @@ -58,7 +58,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version); * Macro to check that the libxml version in use is compatible with * the version the software has been compiled against */ -#define LIBXML_TEST_VERSION xmlCheckVersion(20910); +#define LIBXML_TEST_VERSION xmlCheckVersion(20912); #ifndef VMS #if 0 diff --git a/chromium/third_party/libxml/src/CMakeLists.txt b/chromium/third_party/libxml/src/CMakeLists.txt index a437717ba35..b4c0c7945de 100644 --- a/chromium/third_party/libxml/src/CMakeLists.txt +++ b/chromium/third_party/libxml/src/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) -project(libxml2 VERSION 2.9.10 LANGUAGES C) +project(libxml2 VERSION 2.9.12 LANGUAGES C) include(CheckCSourceCompiles) include(CheckFunctionExists) @@ -414,6 +414,7 @@ if(LIBXML2_WITH_TRIO) endif() add_library(LibXml2 ${LIBXML2_HDRS} ${LIBXML2_SRCS}) +add_library(LibXml2::LibXml2 ALIAS LibXml2) if(NOT BUILD_SHARED_LIBS) target_compile_definitions(LibXml2 INTERFACE LIBXML_STATIC) @@ -537,6 +538,7 @@ if(LIBXML2_WITH_PROGRAMS) ) foreach(PROGRAM ${PROGRAMS}) add_executable(${PROGRAM} ${PROGRAM}.c) + add_executable(LibXml2::${PROGRAM} ALIAS ${PROGRAM}) target_link_libraries(${PROGRAM} LibXml2) if(HAVE_LIBHISTORY) target_link_libraries(${PROGRAM} history) diff --git a/chromium/third_party/libxml/src/HTMLtree.c b/chromium/third_party/libxml/src/HTMLtree.c index 24434d453e1..bdd639c7fc9 100644 --- a/chromium/third_party/libxml/src/HTMLtree.c +++ b/chromium/third_party/libxml/src/HTMLtree.c @@ -744,7 +744,7 @@ void htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const char *encoding ATTRIBUTE_UNUSED, int format) { - xmlNodePtr root; + xmlNodePtr root, parent; xmlAttrPtr attr; const htmlElemDesc * info; @@ -755,6 +755,7 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, } root = cur; + parent = cur->parent; while (1) { switch (cur->type) { case XML_HTML_DOCUMENT_NODE: @@ -762,7 +763,9 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, if (((xmlDocPtr) cur)->intSubset != NULL) { htmlDtdDumpOutput(buf, (xmlDocPtr) cur, NULL); } - if (cur->children != NULL) { + /* Always validate cur->parent when descending. */ + if ((cur->parent == parent) && (cur->children != NULL)) { + parent = cur; cur = cur->children; continue; } @@ -770,6 +773,16 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, case XML_ELEMENT_NODE: /* + * Some users like lxml are known to pass nodes with a corrupted + * tree structure. Fall back to a recursive call to handle this + * case. + */ + if ((cur->parent != parent) && (cur->children != NULL)) { + htmlNodeDumpFormatOutput(buf, doc, cur, encoding, format); + break; + } + + /* * Get specific HTML info for that node. */ if (cur->ns == NULL) @@ -817,6 +830,7 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, (cur->name != NULL) && (cur->name[0] != 'p')) /* p, pre, param */ xmlOutputBufferWriteString(buf, "\n"); + parent = cur; cur = cur->children; continue; } @@ -825,9 +839,9 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, (info != NULL) && (!info->isinline)) { if ((cur->next->type != HTML_TEXT_NODE) && (cur->next->type != HTML_ENTITY_REF_NODE) && - (cur->parent != NULL) && - (cur->parent->name != NULL) && - (cur->parent->name[0] != 'p')) /* p, pre, param */ + (parent != NULL) && + (parent->name != NULL) && + (parent->name[0] != 'p')) /* p, pre, param */ xmlOutputBufferWriteString(buf, "\n"); } @@ -842,9 +856,9 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, break; if (((cur->name == (const xmlChar *)xmlStringText) || (cur->name != (const xmlChar *)xmlStringTextNoenc)) && - ((cur->parent == NULL) || - ((xmlStrcasecmp(cur->parent->name, BAD_CAST "script")) && - (xmlStrcasecmp(cur->parent->name, BAD_CAST "style"))))) { + ((parent == NULL) || + ((xmlStrcasecmp(parent->name, BAD_CAST "script")) && + (xmlStrcasecmp(parent->name, BAD_CAST "style"))))) { xmlChar *buffer; buffer = xmlEncodeEntitiesReentrant(doc, cur->content); @@ -902,13 +916,9 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, break; } - /* - * The parent should never be NULL here but we want to handle - * corrupted documents gracefully. - */ - if (cur->parent == NULL) - return; - cur = cur->parent; + cur = parent; + /* cur->parent was validated when descending. */ + parent = cur->parent; if ((cur->type == XML_HTML_DOCUMENT_NODE) || (cur->type == XML_DOCUMENT_NODE)) { @@ -939,9 +949,9 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, (cur->next != NULL)) { if ((cur->next->type != HTML_TEXT_NODE) && (cur->next->type != HTML_ENTITY_REF_NODE) && - (cur->parent != NULL) && - (cur->parent->name != NULL) && - (cur->parent->name[0] != 'p')) /* p, pre, param */ + (parent != NULL) && + (parent->name != NULL) && + (parent->name[0] != 'p')) /* p, pre, param */ xmlOutputBufferWriteString(buf, "\n"); } } diff --git a/chromium/third_party/libxml/src/configure.ac b/chromium/third_party/libxml/src/configure.ac index a4c675bbdc8..5b161a5450e 100644 --- a/chromium/third_party/libxml/src/configure.ac +++ b/chromium/third_party/libxml/src/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([MAJOR_VERSION], 2) m4_define([MINOR_VERSION], 9) -m4_define([MICRO_VERSION], 10) +m4_define([MICRO_VERSION], 12) AC_INIT([libxml2],[MAJOR_VERSION.MINOR_VERSION.MICRO_VERSION]) AC_CONFIG_SRCDIR([entities.c]) diff --git a/chromium/third_party/libxml/src/encoding.c b/chromium/third_party/libxml/src/encoding.c index cdff6ae7bfb..5e50c1537f0 100644 --- a/chromium/third_party/libxml/src/encoding.c +++ b/chromium/third_party/libxml/src/encoding.c @@ -2629,7 +2629,6 @@ xmlCharEncOutFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out, int written; int writtentot = 0; int toconv; - int output = 0; if (handler == NULL) return(-1); if (out == NULL) return(-1); @@ -2682,8 +2681,6 @@ retry: ret = -3; } - if (ret >= 0) output += ret; - /* * Attempt to handle error cases */ diff --git a/chromium/third_party/libxml/src/include/libxml/Makefile.am b/chromium/third_party/libxml/src/include/libxml/Makefile.am index cf9297aad66..328c1800e8d 100644 --- a/chromium/third_party/libxml/src/include/libxml/Makefile.am +++ b/chromium/third_party/libxml/src/include/libxml/Makefile.am @@ -51,4 +51,4 @@ xmlinc_HEADERS = \ xmlsave.h \ schematron.h -EXTRA_DIST = xmlversion.h.in +EXTRA_DIST = xmlversion.h.in xmlwin32version.h.in diff --git a/chromium/third_party/libxml/src/libxml2.spec b/chromium/third_party/libxml/src/libxml2.spec index 1cd4855cb0e..682dff2036a 100644 --- a/chromium/third_party/libxml/src/libxml2.spec +++ b/chromium/third_party/libxml/src/libxml2.spec @@ -2,7 +2,7 @@ Summary: Library providing XML and HTML support Name: libxml2 -Version: 2.9.10 +Version: 2.9.12 Release: 1%{?dist}%{?extra_release} License: MIT Group: Development/Libraries @@ -204,6 +204,6 @@ rm -fr %{buildroot} %endif # with_python3 %changelog -* Mon May 10 2021 Daniel Veillard <veillard@redhat.com> -- upstream release 2.9.10 see http://xmlsoft.org/news.html +* Mon May 24 2021 Daniel Veillard <veillard@redhat.com> +- upstream release 2.9.12 see http://xmlsoft.org/news.html diff --git a/chromium/third_party/libxml/src/parser.c b/chromium/third_party/libxml/src/parser.c index 9ecd7cfa2ab..34e63d8024a 100644 --- a/chromium/third_party/libxml/src/parser.c +++ b/chromium/third_party/libxml/src/parser.c @@ -14690,7 +14690,8 @@ xmlInitParser(void) { return; #if defined(_WIN32) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)) - atexit(xmlCleanupParser); + if (xmlFree == free) + atexit(xmlCleanupParser); #endif #ifdef LIBXML_THREAD_ENABLED diff --git a/chromium/third_party/libxml/src/testapi.c b/chromium/third_party/libxml/src/testapi.c index 8a4e23e3325..6f19c6fc967 100644 --- a/chromium/third_party/libxml/src/testapi.c +++ b/chromium/third_party/libxml/src/testapi.c @@ -2843,7 +2843,7 @@ test_htmlDocContentDumpFormatOutput(void) { int n_buf; xmlDocPtr cur; /* the document */ int n_cur; - char * encoding; /* the encoding string */ + char * encoding; /* the encoding string (unused) */ int n_encoding; int format; /* should formatting spaces been added */ int n_format; @@ -2896,7 +2896,7 @@ test_htmlDocContentDumpOutput(void) { int n_buf; xmlDocPtr cur; /* the document */ int n_cur; - char * encoding; /* the encoding string */ + char * encoding; /* the encoding string (unused) */ int n_encoding; for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { @@ -3397,7 +3397,7 @@ test_htmlNodeDumpFormatOutput(void) { int n_doc; xmlNodePtr cur; /* the current node */ int n_cur; - char * encoding; /* the encoding string */ + char * encoding; /* the encoding string (unused) */ int n_encoding; int format; /* should formatting spaces been added */ int n_format; @@ -3457,7 +3457,7 @@ test_htmlNodeDumpOutput(void) { int n_doc; xmlNodePtr cur; /* the current node */ int n_cur; - char * encoding; /* the encoding string */ + char * encoding; /* the encoding string (unused) */ int n_encoding; for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { @@ -13611,7 +13611,7 @@ test_xmlParseBalancedChunkMemory(void) { #ifdef LIBXML_SAX1_ENABLED int mem_base; int ret_val; - xmlDocPtr doc; /* the document the chunk pertains to */ + xmlDocPtr doc; /* the document the chunk pertains to (must not be NULL) */ int n_doc; xmlSAXHandlerPtr sax; /* the SAX handler block (possibly NULL) */ int n_sax; @@ -13687,7 +13687,7 @@ test_xmlParseBalancedChunkMemoryRecover(void) { #ifdef LIBXML_SAX1_ENABLED int mem_base; int ret_val; - xmlDocPtr doc; /* the document the chunk pertains to */ + xmlDocPtr doc; /* the document the chunk pertains to (must not be NULL) */ int n_doc; xmlSAXHandlerPtr sax; /* the SAX handler block (possibly NULL) */ int n_sax; @@ -29238,6 +29238,33 @@ test_xmlPopInputCallbacks(void) { static int +test_xmlPopOutputCallbacks(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = xmlPopOutputCallbacks(); + desret_int(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPopOutputCallbacks", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int test_xmlRegisterDefaultInputCallbacks(void) { int test_ret = 0; @@ -29313,7 +29340,7 @@ static int test_xmlIO(void) { int test_ret = 0; - if (quiet == 0) printf("Testing xmlIO : 40 of 50 functions ...\n"); + if (quiet == 0) printf("Testing xmlIO : 41 of 51 functions ...\n"); test_ret += test_xmlAllocOutputBuffer(); test_ret += test_xmlAllocParserInputBuffer(); test_ret += test_xmlCheckFilename(); @@ -29354,6 +29381,7 @@ test_xmlIO(void) { test_ret += test_xmlParserInputBufferPush(); test_ret += test_xmlParserInputBufferRead(); test_ret += test_xmlPopInputCallbacks(); + test_ret += test_xmlPopOutputCallbacks(); test_ret += test_xmlRegisterDefaultInputCallbacks(); test_ret += test_xmlRegisterDefaultOutputCallbacks(); test_ret += test_xmlRegisterHTTPPostCallbacks(); @@ -34240,27 +34268,27 @@ test_xmlSaveTree(void) { long ret_val; xmlSaveCtxtPtr ctxt; /* a document saving context */ int n_ctxt; - xmlNodePtr node; /* the top node of the subtree to save */ - int n_node; + xmlNodePtr cur; /* */ + int n_cur; for (n_ctxt = 0;n_ctxt < gen_nb_xmlSaveCtxtPtr;n_ctxt++) { - for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { mem_base = xmlMemBlocks(); ctxt = gen_xmlSaveCtxtPtr(n_ctxt, 0); - node = gen_xmlNodePtr(n_node, 1); + cur = gen_xmlNodePtr(n_cur, 1); - ret_val = xmlSaveTree(ctxt, node); + ret_val = xmlSaveTree(ctxt, cur); desret_long(ret_val); call_tests++; des_xmlSaveCtxtPtr(n_ctxt, ctxt, 0); - des_xmlNodePtr(n_node, node, 1); + des_xmlNodePtr(n_cur, cur, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSaveTree", xmlMemBlocks() - mem_base); test_ret++; printf(" %d", n_ctxt); - printf(" %d", n_node); + printf(" %d", n_cur); printf("\n"); } } diff --git a/chromium/third_party/libxml/src/xmlsave.c b/chromium/third_party/libxml/src/xmlsave.c index 61a40459bd2..aedbd5e70ac 100644 --- a/chromium/third_party/libxml/src/xmlsave.c +++ b/chromium/third_party/libxml/src/xmlsave.c @@ -847,7 +847,7 @@ htmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { static void xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { int format = ctxt->format; - xmlNodePtr tmp, root, unformattedNode = NULL; + xmlNodePtr tmp, root, unformattedNode = NULL, parent; xmlAttrPtr attr; xmlChar *start, *end; xmlOutputBufferPtr buf; @@ -856,6 +856,7 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { buf = ctxt->buf; root = cur; + parent = cur->parent; while (1) { switch (cur->type) { case XML_DOCUMENT_NODE: @@ -868,7 +869,9 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { break; case XML_DOCUMENT_FRAG_NODE: - if (cur->children != NULL) { + /* Always validate cur->parent when descending. */ + if ((cur->parent == parent) && (cur->children != NULL)) { + parent = cur; cur = cur->children; continue; } @@ -887,7 +890,18 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { break; case XML_ELEMENT_NODE: - if ((cur != root) && (ctxt->format == 1) && (xmlIndentTreeOutput)) + /* + * Some users like lxml are known to pass nodes with a corrupted + * tree structure. Fall back to a recursive call to handle this + * case. + */ + if ((cur->parent != parent) && (cur->children != NULL)) { + xmlNodeDumpOutputInternal(ctxt, cur); + break; + } + + if ((ctxt->level > 0) && (ctxt->format == 1) && + (xmlIndentTreeOutput)) xmlOutputBufferWrite(buf, ctxt->indent_size * (ctxt->level > ctxt->indent_nr ? ctxt->indent_nr : ctxt->level), @@ -942,6 +956,7 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { xmlOutputBufferWrite(buf, 1, ">"); if (ctxt->format == 1) xmlOutputBufferWrite(buf, 1, "\n"); if (ctxt->level >= 0) ctxt->level++; + parent = cur; cur = cur->children; continue; } @@ -1058,13 +1073,9 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { break; } - /* - * The parent should never be NULL here but we want to handle - * corrupted documents gracefully. - */ - if (cur->parent == NULL) - return; - cur = cur->parent; + cur = parent; + /* cur->parent was validated when descending. */ + parent = cur->parent; if (cur->type == XML_ELEMENT_NODE) { if (ctxt->level > 0) ctxt->level--; diff --git a/chromium/third_party/libxml/win32/include/libxml/xmlversion.h b/chromium/third_party/libxml/win32/include/libxml/xmlversion.h index 28ecf084b27..31593eda704 100644 --- a/chromium/third_party/libxml/win32/include/libxml/xmlversion.h +++ b/chromium/third_party/libxml/win32/include/libxml/xmlversion.h @@ -29,21 +29,21 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version); * * the version string like "1.2.3" */ -#define LIBXML_DOTTED_VERSION "2.9.10" +#define LIBXML_DOTTED_VERSION "2.9.12" /** * LIBXML_VERSION: * * the version number: 1.2.3 value is 10203 */ -#define LIBXML_VERSION 20910 +#define LIBXML_VERSION 20912 /** * LIBXML_VERSION_STRING: * * the version number string, 1.2.3 value is "10203" */ -#define LIBXML_VERSION_STRING "20910" +#define LIBXML_VERSION_STRING "20912" /** * LIBXML_VERSION_EXTRA: @@ -58,7 +58,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version); * Macro to check that the libxml version in use is compatible with * the version the software has been compiled against */ -#define LIBXML_TEST_VERSION xmlCheckVersion(20910); +#define LIBXML_TEST_VERSION xmlCheckVersion(20912); #ifndef VMS #if 0 |