From: Amine Khaldi Date: Sat, 9 Jul 2016 18:07:58 +0000 (+0000) Subject: [LIBXML2] Update to v2.9.4. CORE-11556 X-Git-Tag: ReactOS-0.4.2~135 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=5c2ff2467715dd21e85f7b88e126c50e4325d62a [LIBXML2] Update to v2.9.4. CORE-11556 svn path=/trunk/; revision=71875 --- diff --git a/reactos/media/doc/3rd Party Files.txt b/reactos/media/doc/3rd Party Files.txt index 87fe9bfb262..bba0ad81855 100644 --- a/reactos/media/doc/3rd Party Files.txt +++ b/reactos/media/doc/3rd Party Files.txt @@ -43,7 +43,7 @@ Used Version: 1.0.6 Website: http://www.bzip.org Title: LibXML -Used Version: 2.9.3 +Used Version: 2.9.4 Website: http://xmlsoft.org | ftp://xmlsoft.org/libxml2/ Title: Libxslt diff --git a/reactos/sdk/include/reactos/libs/libxml/dict.h b/reactos/sdk/include/reactos/libs/libxml/dict.h index 7022ec8bee7..b83db59a126 100644 --- a/reactos/sdk/include/reactos/libs/libxml/dict.h +++ b/reactos/sdk/include/reactos/libs/libxml/dict.h @@ -1,5 +1,5 @@ /* - * Summary: string dictionnary + * Summary: string dictionary * Description: dictionary of reusable strings, just used to avoid allocation * and freeing operations. * @@ -11,6 +11,18 @@ #ifndef __XML_DICT_H__ #define __XML_DICT_H__ +#ifdef __cplusplus +#define __XML_EXTERNC extern "C" +#else +#define __XML_EXTERNC +#endif + +/* + * The dictionary. + */ +__XML_EXTERNC typedef struct _xmlDict xmlDict; +__XML_EXTERNC typedef xmlDict *xmlDictPtr; + #include #include #include @@ -19,12 +31,6 @@ extern "C" { #endif -/* - * The dictionnary. - */ -typedef struct _xmlDict xmlDict; -typedef xmlDict *xmlDictPtr; - /* * Initializer */ @@ -48,7 +54,7 @@ XMLPUBFUN void XMLCALL xmlDictFree (xmlDictPtr dict); /* - * Lookup of entry in the dictionnary. + * Lookup of entry in the dictionary. */ XMLPUBFUN const xmlChar * XMLCALL xmlDictLookup (xmlDictPtr dict, diff --git a/reactos/sdk/include/reactos/libs/libxml/parser.h b/reactos/sdk/include/reactos/libs/libxml/parser.h index 3f5730dc61b..47fbec03f7e 100644 --- a/reactos/sdk/include/reactos/libs/libxml/parser.h +++ b/reactos/sdk/include/reactos/libs/libxml/parser.h @@ -260,7 +260,7 @@ struct _xmlParserCtxt { void *catalogs; /* document's own catalog */ int recovery; /* run in recovery mode */ int progressive; /* is this a progressive parsing */ - xmlDictPtr dict; /* dictionnary for the parser */ + xmlDictPtr dict; /* dictionary for the parser */ const xmlChar * *atts; /* array for the attributes callbacks */ int maxatts; /* the size of the array */ int docdict; /* use strings from dict to build tree */ @@ -1099,7 +1099,7 @@ typedef enum { XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */ XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */ XML_PARSE_NONET = 1<<11,/* Forbid network access */ - XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */ + XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */ XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */ XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */ XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */ diff --git a/reactos/sdk/include/reactos/libs/libxml/parserInternals.h b/reactos/sdk/include/reactos/libs/libxml/parserInternals.h index 6065320eb13..f30fc6876d6 100644 --- a/reactos/sdk/include/reactos/libs/libxml/parserInternals.h +++ b/reactos/sdk/include/reactos/libs/libxml/parserInternals.h @@ -351,7 +351,7 @@ XMLPUBFUN void XMLCALL xmlParserErrors xmlerr, const char *msg, const xmlChar * str1, - const xmlChar * str2); + const xmlChar * str2) LIBXML_ATTR_FORMAT(3,0); #endif /** diff --git a/reactos/sdk/include/reactos/libs/libxml/schemasInternals.h b/reactos/sdk/include/reactos/libs/libxml/schemasInternals.h index 4f0ca9a1fd6..c7cf55255a0 100644 --- a/reactos/sdk/include/reactos/libs/libxml/schemasInternals.h +++ b/reactos/sdk/include/reactos/libs/libxml/schemasInternals.h @@ -28,52 +28,52 @@ extern "C" { typedef enum { XML_SCHEMAS_UNKNOWN = 0, - XML_SCHEMAS_STRING, - XML_SCHEMAS_NORMSTRING, - XML_SCHEMAS_DECIMAL, - XML_SCHEMAS_TIME, - XML_SCHEMAS_GDAY, - XML_SCHEMAS_GMONTH, - XML_SCHEMAS_GMONTHDAY, - XML_SCHEMAS_GYEAR, - XML_SCHEMAS_GYEARMONTH, - XML_SCHEMAS_DATE, - XML_SCHEMAS_DATETIME, - XML_SCHEMAS_DURATION, - XML_SCHEMAS_FLOAT, - XML_SCHEMAS_DOUBLE, - XML_SCHEMAS_BOOLEAN, - XML_SCHEMAS_TOKEN, - XML_SCHEMAS_LANGUAGE, - XML_SCHEMAS_NMTOKEN, - XML_SCHEMAS_NMTOKENS, - XML_SCHEMAS_NAME, - XML_SCHEMAS_QNAME, - XML_SCHEMAS_NCNAME, - XML_SCHEMAS_ID, - XML_SCHEMAS_IDREF, - XML_SCHEMAS_IDREFS, - XML_SCHEMAS_ENTITY, - XML_SCHEMAS_ENTITIES, - XML_SCHEMAS_NOTATION, - XML_SCHEMAS_ANYURI, - XML_SCHEMAS_INTEGER, - XML_SCHEMAS_NPINTEGER, - XML_SCHEMAS_NINTEGER, - XML_SCHEMAS_NNINTEGER, - XML_SCHEMAS_PINTEGER, - XML_SCHEMAS_INT, - XML_SCHEMAS_UINT, - XML_SCHEMAS_LONG, - XML_SCHEMAS_ULONG, - XML_SCHEMAS_SHORT, - XML_SCHEMAS_USHORT, - XML_SCHEMAS_BYTE, - XML_SCHEMAS_UBYTE, - XML_SCHEMAS_HEXBINARY, - XML_SCHEMAS_BASE64BINARY, - XML_SCHEMAS_ANYTYPE, - XML_SCHEMAS_ANYSIMPLETYPE + XML_SCHEMAS_STRING = 1, + XML_SCHEMAS_NORMSTRING = 2, + XML_SCHEMAS_DECIMAL = 3, + XML_SCHEMAS_TIME = 4, + XML_SCHEMAS_GDAY = 5, + XML_SCHEMAS_GMONTH = 6, + XML_SCHEMAS_GMONTHDAY = 7, + XML_SCHEMAS_GYEAR = 8, + XML_SCHEMAS_GYEARMONTH = 9, + XML_SCHEMAS_DATE = 10, + XML_SCHEMAS_DATETIME = 11, + XML_SCHEMAS_DURATION = 12, + XML_SCHEMAS_FLOAT = 13, + XML_SCHEMAS_DOUBLE = 14, + XML_SCHEMAS_BOOLEAN = 15, + XML_SCHEMAS_TOKEN = 16, + XML_SCHEMAS_LANGUAGE = 17, + XML_SCHEMAS_NMTOKEN = 18, + XML_SCHEMAS_NMTOKENS = 19, + XML_SCHEMAS_NAME = 20, + XML_SCHEMAS_QNAME = 21, + XML_SCHEMAS_NCNAME = 22, + XML_SCHEMAS_ID = 23, + XML_SCHEMAS_IDREF = 24, + XML_SCHEMAS_IDREFS = 25, + XML_SCHEMAS_ENTITY = 26, + XML_SCHEMAS_ENTITIES = 27, + XML_SCHEMAS_NOTATION = 28, + XML_SCHEMAS_ANYURI = 29, + XML_SCHEMAS_INTEGER = 30, + XML_SCHEMAS_NPINTEGER = 31, + XML_SCHEMAS_NINTEGER = 32, + XML_SCHEMAS_NNINTEGER = 33, + XML_SCHEMAS_PINTEGER = 34, + XML_SCHEMAS_INT = 35, + XML_SCHEMAS_UINT = 36, + XML_SCHEMAS_LONG = 37, + XML_SCHEMAS_ULONG = 38, + XML_SCHEMAS_SHORT = 39, + XML_SCHEMAS_USHORT = 40, + XML_SCHEMAS_BYTE = 41, + XML_SCHEMAS_UBYTE = 42, + XML_SCHEMAS_HEXBINARY = 43, + XML_SCHEMAS_BASE64BINARY = 44, + XML_SCHEMAS_ANYTYPE = 45, + XML_SCHEMAS_ANYSIMPLETYPE = 46 } xmlSchemaValType; /* diff --git a/reactos/sdk/include/reactos/libs/libxml/xmlerror.h b/reactos/sdk/include/reactos/libs/libxml/xmlerror.h index 43e68ca5935..037c16d5704 100644 --- a/reactos/sdk/include/reactos/libs/libxml/xmlerror.h +++ b/reactos/sdk/include/reactos/libs/libxml/xmlerror.h @@ -937,7 +937,7 @@ XMLPUBFUN void XMLCALL int code, xmlNodePtr node, const char *msg, - const char *extra); + const char *extra) LIBXML_ATTR_FORMAT(4,0); #endif #ifdef __cplusplus } diff --git a/reactos/sdk/include/reactos/libs/libxml/xmlstring.h b/reactos/sdk/include/reactos/libs/libxml/xmlstring.h index 20362365825..2d0b2d1668e 100644 --- a/reactos/sdk/include/reactos/libs/libxml/xmlstring.h +++ b/reactos/sdk/include/reactos/libs/libxml/xmlstring.h @@ -97,13 +97,13 @@ XMLPUBFUN xmlChar * XMLCALL XMLPUBFUN int XMLCALL xmlStrPrintf (xmlChar *buf, int len, - const xmlChar *msg, - ...); + const char *msg, + ...) LIBXML_ATTR_FORMAT(3,4); XMLPUBFUN int XMLCALL xmlStrVPrintf (xmlChar *buf, int len, - const xmlChar *msg, - va_list ap); + const char *msg, + va_list ap) LIBXML_ATTR_FORMAT(3,0); XMLPUBFUN int XMLCALL xmlGetUTF8Char (const unsigned char *utf, diff --git a/reactos/sdk/include/reactos/libs/libxml/xmlversion.h b/reactos/sdk/include/reactos/libs/libxml/xmlversion.h index 0c4e1c375f3..7f200055b2e 100644 --- a/reactos/sdk/include/reactos/libs/libxml/xmlversion.h +++ b/reactos/sdk/include/reactos/libs/libxml/xmlversion.h @@ -29,28 +29,28 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version); * * the version string like "1.2.3" */ -#define LIBXML_DOTTED_VERSION "2.9.3" +#define LIBXML_DOTTED_VERSION "2.9.4" /** * LIBXML_VERSION: * * the version number: 1.2.3 value is 10203 */ -#define LIBXML_VERSION 20903 +#define LIBXML_VERSION 20904 /** * LIBXML_VERSION_STRING: * * the version number string, 1.2.3 value is "10203" */ -#define LIBXML_VERSION_STRING "20903" +#define LIBXML_VERSION_STRING "20904" /** * LIBXML_VERSION_EXTRA: * * extra version information, used to show a CVS compilation */ -#define LIBXML_VERSION_EXTRA "-GITCVE-2015-8242" +#define LIBXML_VERSION_EXTRA "-GITCVE-2016-1834-21-g502f6a6" /** * LIBXML_TEST_VERSION: @@ -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(20903); +#define LIBXML_TEST_VERSION xmlCheckVersion(20904); #ifndef VMS #if 0 diff --git a/reactos/sdk/include/reactos/libs/libxml/xpathInternals.h b/reactos/sdk/include/reactos/libs/libxml/xpathInternals.h index 70c9db96f18..76a6b481572 100644 --- a/reactos/sdk/include/reactos/libs/libxml/xpathInternals.h +++ b/reactos/sdk/include/reactos/libs/libxml/xpathInternals.h @@ -229,7 +229,7 @@ XMLPUBFUN void * XMLCALL * Empties a node-set. */ #define xmlXPathEmptyNodeSet(ns) \ - { while ((ns)->nodeNr > 0) (ns)->nodeTab[(ns)->nodeNr--] = NULL; } + { while ((ns)->nodeNr > 0) (ns)->nodeTab[--(ns)->nodeNr] = NULL; } /** * CHECK_ERROR: diff --git a/reactos/sdk/lib/3rdparty/libxml2/ChangeLog b/reactos/sdk/lib/3rdparty/libxml2/ChangeLog index 08725dd3d2e..ef6cb8e427f 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/ChangeLog +++ b/reactos/sdk/lib/3rdparty/libxml2/ChangeLog @@ -593,7 +593,7 @@ Thu Apr 24 13:56:53 CEST 2008 Daniel Veillard Tue Apr 22 10:27:17 CEST 2008 Daniel Veillard - * dict.c: improvement on the hashing of the dictionnary, with visible + * dict.c: improvement on the hashing of the dictionary, with visible speed up as the number of strings in the hash increases, work from Stefan Behnel @@ -5017,7 +5017,7 @@ Mon Jan 24 00:47:41 CET 2005 Daniel Veillard Sun Jan 23 23:54:39 CET 2005 Daniel Veillard * hash.c include/libxml/hash.h: added xmlHashCreateDict where - the hash reuses the dictionnary for internal strings + the hash reuses the dictionary for internal strings * entities.c valid.c parser.c: reuse that new API, leads to a decent speedup when parsing for example DocBook documents. @@ -5371,7 +5371,7 @@ Fri Nov 26 11:44:36 CET 2004 Daniel Veillard Wed Nov 24 13:41:52 CET 2004 Daniel Veillard * dict.c include/libxml/dict.h: added xmlDictExists() to the - dictionnary interface. + dictionary interface. * xmlreader.c: applying xmlTextReaderHasAttributes fix for namespaces from Rob Richards @@ -5697,7 +5697,7 @@ Tue Oct 26 23:57:02 CEST 2004 Daniel Veillard Tue Oct 26 18:09:59 CEST 2004 Daniel Veillard * debugXML.c include/libxml/xmlerror.h: added checking for names - values and dictionnaries generates a tons of errors + values and dictionaries generates a tons of errors * SAX2.ccatalog.c parser.c relaxng.c tree.c xinclude.c xmlwriter.c include/libxml/tree.h: fixing the errors in the regression tests @@ -7746,14 +7746,14 @@ Fri Jan 23 14:03:21 CET 2004 Daniel Veillard make tests * xpath.c include/libxml/xpath.h: added xmlXPathCtxtCompile() to compile an XPath expression within a context, currently the goal - is to be able to reuse the XSLT stylesheet dictionnary, but this + is to be able to reuse the XSLT stylesheet dictionary, but this opens the door to others possible optimizations. * dict.c include/libxml/dict.h: added xmlDictCreateSub() which allows - to build a new dictionnary based on another read-only dictionnary. - This is needed for XSLT to keep the stylesheet dictionnary read-only + to build a new dictionary based on another read-only dictionary. + This is needed for XSLT to keep the stylesheet dictionary read-only while being able to reuse the strings for the transformation - dictionnary. - * xinclude.c: fixed a dictionnar reference counting problem occuring + dictionary. + * xinclude.c: fixed a dictionary reference counting problem occuring when document parsing failed. * testSAX.c: adding option --repeat for timing 100times the parsing * doc/* : rebuilt all the docs @@ -7806,7 +7806,7 @@ Mon Jan 12 17:22:57 CET 2004 Daniel Veillard Thu Jan 8 17:57:50 CET 2004 Daniel Veillard * xmlschemas.c: removed a memory leak remaining from the switch - to a dictionnary for string allocations c.f. #130891 + to a dictionary for string allocations c.f. #130891 Thu Jan 8 17:48:46 CET 2004 Daniel Veillard @@ -7928,7 +7928,7 @@ Fri Jan 2 22:58:29 HKT 2004 William Brack Fri Jan 2 11:40:06 CET 2004 Daniel Veillard * SAX2.c: found and fixed a bug misallocating some non - blank text node strings from the dictionnary. + blank text node strings from the dictionary. * xmlmemory.c: fixed a problem with the memory debug mutex release. @@ -9386,7 +9386,7 @@ Sat Sep 27 01:25:39 CEST 2003 Daniel Veillard * parser.c: William's change allowed to spot a nasty bug in xmlDoRead if the result is not well formed that ctxt->myDoc is not NULL - and uses the context dictionnary. + and uses the context dictionary. Fri Sep 26 21:09:34 CEST 2003 Daniel Veillard diff --git a/reactos/sdk/lib/3rdparty/libxml2/HTMLparser.c b/reactos/sdk/lib/3rdparty/libxml2/HTMLparser.c index b7291972ef8..d1395fa507c 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/HTMLparser.c +++ b/reactos/sdk/lib/3rdparty/libxml2/HTMLparser.c @@ -105,7 +105,7 @@ htmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra) * * Handle a fatal parser error, i.e. violating Well-Formedness constraints */ -static void +static void LIBXML_ATTR_FORMAT(3,0) htmlParseErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, const xmlChar *str2) { @@ -132,7 +132,7 @@ htmlParseErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a fatal parser error, i.e. violating Well-Formedness constraints */ -static void +static void LIBXML_ATTR_FORMAT(3,0) htmlParseErrInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, int val) { @@ -303,6 +303,7 @@ htmlNodeInfoPop(htmlParserCtxtPtr ctxt) #define UPP(val) (toupper(ctxt->input->cur[(val)])) #define CUR_PTR ctxt->input->cur +#define BASE_PTR ctxt->input->base #define SHRINK if ((ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \ (ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \ @@ -2471,6 +2472,10 @@ htmlParseName(htmlParserCtxtPtr ctxt) { (*in == '_') || (*in == '-') || (*in == ':') || (*in == '.')) in++; + + if (in == ctxt->input->end) + return(NULL); + if ((*in > 0) && (*in < 0x80)) { count = in - ctxt->input->cur; ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count); @@ -2488,6 +2493,7 @@ htmlParseNameComplex(xmlParserCtxtPtr ctxt) { int len = 0, l; int c; int count = 0; + const xmlChar *base = ctxt->input->base; /* * Handler for more complex cases @@ -2513,7 +2519,18 @@ htmlParseNameComplex(xmlParserCtxtPtr ctxt) { len += l; NEXTL(l); c = CUR_CHAR(l); + if (ctxt->input->base != base) { + /* + * We changed encoding from an unknown encoding + * Input buffer changed location, so we better start again + */ + return(htmlParseNameComplex(ctxt)); + } } + + if (ctxt->input->base > ctxt->input->cur - len) + return(NULL); + return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len)); } @@ -2765,31 +2782,43 @@ htmlParseAttValue(htmlParserCtxtPtr ctxt) { static xmlChar * htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) { - const xmlChar *q; + size_t len = 0, startPosition = 0; xmlChar *ret = NULL; if (CUR == '"') { NEXT; - q = CUR_PTR; - while ((IS_CHAR_CH(CUR)) && (CUR != '"')) + + if (CUR_PTR < BASE_PTR) + return(ret); + startPosition = CUR_PTR - BASE_PTR; + + while ((IS_CHAR_CH(CUR)) && (CUR != '"')) { NEXT; + len++; + } if (!IS_CHAR_CH(CUR)) { htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, "Unfinished SystemLiteral\n", NULL, NULL); } else { - ret = xmlStrndup(q, CUR_PTR - q); + ret = xmlStrndup((BASE_PTR+startPosition), len); NEXT; } } else if (CUR == '\'') { NEXT; - q = CUR_PTR; - while ((IS_CHAR_CH(CUR)) && (CUR != '\'')) + + if (CUR_PTR < BASE_PTR) + return(ret); + startPosition = CUR_PTR - BASE_PTR; + + while ((IS_CHAR_CH(CUR)) && (CUR != '\'')) { NEXT; + len++; + } if (!IS_CHAR_CH(CUR)) { htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, "Unfinished SystemLiteral\n", NULL, NULL); } else { - ret = xmlStrndup(q, CUR_PTR - q); + ret = xmlStrndup((BASE_PTR+startPosition), len); NEXT; } } else { @@ -2813,32 +2842,47 @@ htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) { static xmlChar * htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) { - const xmlChar *q; + size_t len = 0, startPosition = 0; xmlChar *ret = NULL; /* * Name ::= (Letter | '_') (NameChar)* */ if (CUR == '"') { NEXT; - q = CUR_PTR; - while (IS_PUBIDCHAR_CH(CUR)) NEXT; + + if (CUR_PTR < BASE_PTR) + return(ret); + startPosition = CUR_PTR - BASE_PTR; + + while (IS_PUBIDCHAR_CH(CUR)) { + len++; + NEXT; + } + if (CUR != '"') { htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, "Unfinished PubidLiteral\n", NULL, NULL); } else { - ret = xmlStrndup(q, CUR_PTR - q); + ret = xmlStrndup((BASE_PTR + startPosition), len); NEXT; } } else if (CUR == '\'') { NEXT; - q = CUR_PTR; - while ((IS_PUBIDCHAR_CH(CUR)) && (CUR != '\'')) - NEXT; + + if (CUR_PTR < BASE_PTR) + return(ret); + startPosition = CUR_PTR - BASE_PTR; + + while ((IS_PUBIDCHAR_CH(CUR)) && (CUR != '\'')){ + len++; + NEXT; + } + if (CUR != '\'') { htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, "Unfinished PubidLiteral\n", NULL, NULL); } else { - ret = xmlStrndup(q, CUR_PTR - q); + ret = xmlStrndup((BASE_PTR + startPosition), len); NEXT; } } else { @@ -6537,7 +6581,7 @@ htmlNodeStatus(const htmlNodePtr node, int legacy) { * DICT_FREE: * @str: a string * - * Free a string if it is not owned by the "dict" dictionnary in the + * Free a string if it is not owned by the "dict" dictionary in the * current scope */ #define DICT_FREE(str) \ diff --git a/reactos/sdk/lib/3rdparty/libxml2/NEWS b/reactos/sdk/lib/3rdparty/libxml2/NEWS index 8027d55c0fd..d248c6936f5 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/NEWS +++ b/reactos/sdk/lib/3rdparty/libxml2/NEWS @@ -845,7 +845,7 @@ Gansterer), - Improvement: switch parser to XML-1.0 5th edition, add parsing flags for old versions, switch URI parsing to RFC 3986, add xmlSchemaValidCtxtGetParserCtxt (Holger Kaelberer), - new hashing functions for dictionnaries (based on Stefan Behnel work), + new hashing functions for dictionaries (based on Stefan Behnel work), improve handling of misplaced html/head/body in HTML parser, better regression test tools and code coverage display, better algorithms to detect various versions of the billion laughts attacks, make @@ -1231,7 +1231,7 @@ Do not use or package 2.6.25 Bakefile support (Francesco Montorsi), Windows compilation (Joel Reed), some gcc4 fixes, HP-UX portability fixes (Rick Jones). - bug fixes: xmlSchemaElementDump namespace (Kasimier Buchcik), push and - xmlreader stopping on non-fatal errors, thread support for dictionnaries + xmlreader stopping on non-fatal errors, thread support for dictionaries reference counting (Gary Coady), internal subset and push problem, URL saved in xmlCopyDoc, various schemas bug fixes (Kasimier), Python paths fixup (Stephane Bidoul), xmlGetNodePath and namespaces, xmlSetNsProp fix @@ -1244,7 +1244,7 @@ Do not use or package 2.6.25 Hendricks), aliasing bug exposed by gcc4 on s390, xmlTextReaderNext bug (Rob Richards), Schemas decimal type fixes (William Brack), xmlByteConsumed static buffer (Ben Maurer). - - improvement: speedup parsing comments and DTDs, dictionnary support for + - improvement: speedup parsing comments and DTDs, dictionary support for hash tables, Schemas Identity constraints (Kasimier), streaming XPath subset, xmlTextReaderReadString added (Bjorn Reese), Schemas canonical values handling (Kasimier), add xmlTextReaderByteConsumed (Aron @@ -1454,7 +1454,7 @@ Do not use or package 2.6.25 URI on SYSTEM lookup failure, XInclude parse flags inheritance (William), XInclude and XPointer fixes for entities (William), XML parser bug reported by Holger Rauch, nanohttp fd leak (William), regexps char - groups '-' handling (William), dictionnary reference counting problems, + groups '-' handling (William), dictionary reference counting problems, do not close stderr. - performance patches from Petr Pajas - Documentation fixes: XML_CATALOG_FILES in man pages (Mike Hommey) @@ -1482,7 +1482,7 @@ Do not use or package 2.6.25 William) reported by Yuuichi Teranishi - bugfixes: make test and path issues, xmlWriter attribute serialization (William Brack), xmlWriter indentation (William), schemas validation - (Eric Haszlakiewicz), XInclude dictionnaries issues (William and Oleg + (Eric Haszlakiewicz), XInclude dictionaries issues (William and Oleg Paraschenko), XInclude empty fallback (William), HTML warnings (William), XPointer in XInclude (William), Python namespace serialization, isolat1ToUTF8 bound error (Alfred Mickautsch), output of parameter @@ -1503,7 +1503,7 @@ Do not use or package 2.6.25 2.6.5: Jan 25 2004: - - Bugfixes: dictionnaries for schemas (William Brack), regexp segfault + - Bugfixes: dictionaries for schemas (William Brack), regexp segfault (William), xs:all problem (William), a number of XPointer bugfixes (William), xmllint error go to stderr, DTD validation problem with namespace, memory leak (William), SAX1 cleanup and minimal options fixes @@ -1515,14 +1515,14 @@ Do not use or package 2.6.25 Fleck), doc (Sven Zimmerman), I/O example. - Python bindings: fixes (William), enum support (Stéphane Bidoul), structured error reporting (Stéphane Bidoul) - - XInclude: various fixes for conformance, problem related to dictionnary + - XInclude: various fixes for conformance, problem related to dictionary references (William & me), recursion (William) - xmlWriter: indentation (Lucas Brasilino), memory leaks (Alfred Mickautsch), - xmlSchemas: normalizedString datatype (John Belmonte) - code cleanup for strings functions (William) - Windows: compiler patches (Mark Vakoc) - - Parser optimizations, a few new XPath and dictionnary APIs for future + - Parser optimizations, a few new XPath and dictionary APIs for future XSLT optimizations. @@ -1617,8 +1617,8 @@ Do not use or package 2.6.25 of change - Increased the library modularity, far more options can be stripped out, a --with-minimum configuration will weight around 160KBytes - - Use per parser and per document dictionnary, allocate names and small - text nodes from the dictionnary + - Use per parser and per document dictionary, allocate names and small + text nodes from the dictionary - Switch to a SAX2 like parser rewrote most of the XML parser core, provides namespace resolution and defaulted attributes, minimize memory allocations and copies, namespace checking and specific error handling, @@ -1665,7 +1665,7 @@ Do not use or package 2.6.25 (William), xmlCleanupParser (Marc Liyanage), CDATA output (William), HTTP error handling. - xmllint options: --dtdvalidfpi for Tobias Reif, --sax1 for compat - testing, --nodict for building without tree dictionnary, --nocdata to + testing, --nodict for building without tree dictionary, --nocdata to replace CDATA by text, --nsclean to remove surperfluous namespace declarations - added xml2-config --libtool-libs option from Kevin P. Fleming diff --git a/reactos/sdk/lib/3rdparty/libxml2/SAX2.c b/reactos/sdk/lib/3rdparty/libxml2/SAX2.c index ffef3e14689..5cbb700af54 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/SAX2.c +++ b/reactos/sdk/lib/3rdparty/libxml2/SAX2.c @@ -55,7 +55,7 @@ * @ctxt: an XML validation parser context * @msg: a string to accompany the error message */ -static void +static void LIBXML_ATTR_FORMAT(2,0) xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) { xmlStructuredErrorFunc schannel = NULL; const char *str1 = "out of memory\n"; @@ -93,7 +93,7 @@ xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) { * * Handle a validation error */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlErrValid(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const char *str1, const char *str2) { @@ -133,7 +133,7 @@ xmlErrValid(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a fatal parser error, i.e. violating Well-Formedness constraints */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, const xmlChar *str2) { @@ -164,7 +164,7 @@ xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a parser warning */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1) { @@ -189,7 +189,7 @@ xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a namespace error */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, const xmlChar *str2) { @@ -213,7 +213,7 @@ xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a namespace warning */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlNsWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, const xmlChar *str2) { diff --git a/reactos/sdk/lib/3rdparty/libxml2/catalog.c b/reactos/sdk/lib/3rdparty/libxml2/catalog.c index 5773db3de5b..6dfdfbb8ca6 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/catalog.c +++ b/reactos/sdk/lib/3rdparty/libxml2/catalog.c @@ -47,9 +47,9 @@ #define MAX_CATAL_DEPTH 50 #ifdef _WIN32 -# define PATH_SEAPARATOR ';' +# define PATH_SEPARATOR ';' #else -# define PATH_SEAPARATOR ':' +# define PATH_SEPARATOR ':' #endif /** @@ -238,7 +238,7 @@ xmlCatalogErrMemory(const char *extra) * * Handle a catalog error */ -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlCatalogErr(xmlCatalogEntryPtr catal, xmlNodePtr node, int error, const char *msg, const xmlChar *str1, const xmlChar *str2, const xmlChar *str3) @@ -3247,7 +3247,7 @@ xmlLoadCatalogs(const char *pathss) { while (xmlIsBlank_ch(*cur)) cur++; if (*cur != 0) { paths = cur; - while ((*cur != 0) && (*cur != PATH_SEAPARATOR) && (!xmlIsBlank_ch(*cur))) + while ((*cur != 0) && (*cur != PATH_SEPARATOR) && (!xmlIsBlank_ch(*cur))) cur++; path = xmlStrndup((const xmlChar *)paths, cur - paths); #ifdef _WIN32 @@ -3263,7 +3263,7 @@ xmlLoadCatalogs(const char *pathss) { xmlFree(path); } } - while (*cur == PATH_SEAPARATOR) + while (*cur == PATH_SEPARATOR) cur++; } } diff --git a/reactos/sdk/lib/3rdparty/libxml2/debugXML.c b/reactos/sdk/lib/3rdparty/libxml2/debugXML.c index b05fdff527a..a1b550ac534 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/debugXML.c +++ b/reactos/sdk/lib/3rdparty/libxml2/debugXML.c @@ -44,10 +44,10 @@ struct _xmlDebugCtxt { int depth; /* current depth */ xmlDocPtr doc; /* current document */ xmlNodePtr node; /* current node */ - xmlDictPtr dict; /* the doc dictionnary */ + xmlDictPtr dict; /* the doc dictionary */ int check; /* do just checkings */ int errors; /* number of errors found */ - int nodict; /* if the document has no dictionnary */ + int nodict; /* if the document has no dictionary */ int options; /* options */ }; @@ -164,7 +164,7 @@ xmlDebugErr(xmlDebugCtxtPtr ctxt, int error, const char *msg) NULL, NULL, NULL, 0, 0, "%s", msg); } -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra) { ctxt->errors++; @@ -174,7 +174,7 @@ xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra) NULL, NULL, NULL, 0, 0, msg, extra); } -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, const char *extra) { ctxt->errors++; @@ -243,7 +243,7 @@ xmlCtxtCheckString(xmlDebugCtxtPtr ctxt, const xmlChar * str) * @ctxt: the debug context * @name: the name * - * Do debugging on the name, for example the dictionnary status and + * Do debugging on the name, for example the dictionary status and * conformance to the Name production. */ static void @@ -265,7 +265,7 @@ xmlCtxtCheckName(xmlDebugCtxtPtr ctxt, const xmlChar * name) ((ctxt->doc == NULL) || ((ctxt->doc->parseFlags & (XML_PARSE_SAX1 | XML_PARSE_NODICT)) == 0))) { xmlDebugErr3(ctxt, XML_CHECK_OUTSIDE_DICT, - "Name is not from the document dictionnary '%s'", + "Name is not from the document dictionary '%s'", (const char *) name); } } @@ -292,7 +292,7 @@ xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) { /* desactivated right now as it raises too many errors */ if (doc->type == XML_DOCUMENT_NODE) xmlDebugErr(ctxt, XML_CHECK_NO_DICT, - "Document has no dictionnary\n"); + "Document has no dictionary\n"); #endif ctxt->nodict = 1; } diff --git a/reactos/sdk/lib/3rdparty/libxml2/dict.c b/reactos/sdk/lib/3rdparty/libxml2/dict.c index 8c8f93148b6..c0585fe2396 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/dict.c +++ b/reactos/sdk/lib/3rdparty/libxml2/dict.c @@ -87,7 +87,7 @@ typedef unsigned __int32 uint32_t; #endif /* WITH_BIG_KEY */ /* - * An entry in the dictionnary + * An entry in the dictionary */ typedef struct _xmlDictEntry xmlDictEntry; typedef xmlDictEntry *xmlDictEntryPtr; @@ -110,7 +110,7 @@ struct _xmlDictStrings { xmlChar array[1]; }; /* - * The entire dictionnary + * The entire dictionary */ struct _xmlDict { int ref_counter; @@ -229,7 +229,7 @@ xmlDictCleanup(void) { /* * xmlDictAddString: - * @dict: the dictionnary + * @dict: the dictionary * @name: the name of the userdata * @len: the length of the name * @@ -291,7 +291,7 @@ found_pool: /* * xmlDictAddQString: - * @dict: the dictionnary + * @dict: the dictionary * @prefix: the prefix of the userdata * @plen: the prefix length * @name: the name of the userdata @@ -533,7 +533,7 @@ xmlDictComputeFastQKey(const xmlChar *prefix, int plen, * * Create a new dictionary * - * Returns the newly created dictionnary, or NULL if an error occured. + * Returns the newly created dictionary, or NULL if an error occured. */ xmlDictPtr xmlDictCreate(void) { @@ -573,14 +573,14 @@ xmlDictCreate(void) { /** * xmlDictCreateSub: - * @sub: an existing dictionnary + * @sub: an existing dictionary * * Create a new dictionary, inheriting strings from the read-only - * dictionnary @sub. On lookup, strings are first searched in the - * new dictionnary, then in @sub, and if not found are created in the - * new dictionnary. + * dictionary @sub. On lookup, strings are first searched in the + * new dictionary, then in @sub, and if not found are created in the + * new dictionary. * - * Returns the newly created dictionnary, or NULL if an error occured. + * Returns the newly created dictionary, or NULL if an error occured. */ xmlDictPtr xmlDictCreateSub(xmlDictPtr sub) { @@ -599,7 +599,7 @@ xmlDictCreateSub(xmlDictPtr sub) { /** * xmlDictReference: - * @dict: the dictionnary + * @dict: the dictionary * * Increment the reference counter of a dictionary * @@ -620,10 +620,10 @@ xmlDictReference(xmlDictPtr dict) { /** * xmlDictGrow: - * @dict: the dictionnary - * @size: the new size of the dictionnary + * @dict: the dictionary + * @size: the new size of the dictionary * - * resize the dictionnary + * resize the dictionary * * Returns 0 in case of success, -1 in case of failure */ @@ -755,7 +755,7 @@ xmlDictGrow(xmlDictPtr dict, size_t size) { /** * xmlDictFree: - * @dict: the dictionnary + * @dict: the dictionary * * Free the hash @dict and its contents. The userdata is * deallocated with @f if provided. @@ -817,11 +817,11 @@ xmlDictFree(xmlDictPtr dict) { /** * xmlDictLookup: - * @dict: the dictionnary + * @dict: the dictionary * @name: the name of the userdata * @len: the length of the name, if -1 it is recomputed * - * Add the @name to the dictionnary @dict if not present. + * Add the @name to the dictionary @dict if not present. * * Returns the internal copy of the name or NULL in case of internal error */ @@ -957,11 +957,11 @@ xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) { /** * xmlDictExists: - * @dict: the dictionnary + * @dict: the dictionary * @name: the name of the userdata * @len: the length of the name, if -1 it is recomputed * - * Check if the @name exists in the dictionnary @dict. + * Check if the @name exists in the dictionary @dict. * * Returns the internal copy of the name or NULL if not found. */ @@ -1065,7 +1065,7 @@ xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) { /** * xmlDictQLookup: - * @dict: the dictionnary + * @dict: the dictionary * @prefix: the prefix * @name: the name * @@ -1170,7 +1170,7 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) { /** * xmlDictOwns: - * @dict: the dictionnary + * @dict: the dictionary * @str: the string * * check if a string is owned by the disctionary @@ -1197,11 +1197,11 @@ xmlDictOwns(xmlDictPtr dict, const xmlChar *str) { /** * xmlDictSize: - * @dict: the dictionnary + * @dict: the dictionary * * Query the number of elements installed in the hash @dict. * - * Returns the number of elements in the dictionnary or + * Returns the number of elements in the dictionary or * -1 in case of error */ int @@ -1215,7 +1215,7 @@ xmlDictSize(xmlDictPtr dict) { /** * xmlDictSetLimit: - * @dict: the dictionnary + * @dict: the dictionary * @limit: the limit in bytes * * Set a size limit for the dictionary @@ -1236,7 +1236,7 @@ xmlDictSetLimit(xmlDictPtr dict, size_t limit) { /** * xmlDictGetUsage: - * @dict: the dictionnary + * @dict: the dictionary * * Get how much memory is used by a dictionary for strings * Added in 2.9.0 diff --git a/reactos/sdk/lib/3rdparty/libxml2/encoding.c b/reactos/sdk/lib/3rdparty/libxml2/encoding.c index 574e1aedeb4..e49c7f898fc 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/encoding.c +++ b/reactos/sdk/lib/3rdparty/libxml2/encoding.c @@ -93,7 +93,7 @@ xmlEncodingErrMemory(const char *extra) * * n encoding error */ -static void +static void LIBXML_ATTR_FORMAT(2,0) xmlEncodingErr(xmlParserErrors error, const char *msg, const char *val) { __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, diff --git a/reactos/sdk/lib/3rdparty/libxml2/entities.c b/reactos/sdk/lib/3rdparty/libxml2/entities.c index c59423719ec..c40e2cf98ce 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/entities.c +++ b/reactos/sdk/lib/3rdparty/libxml2/entities.c @@ -83,7 +83,7 @@ xmlEntitiesErrMemory(const char *extra) * * Handle an out of memory condition */ -static void +static void LIBXML_ATTR_FORMAT(2,0) xmlEntitiesErr(xmlParserErrors code, const char *msg) { __xmlSimpleError(XML_FROM_TREE, code, NULL, msg, NULL); diff --git a/reactos/sdk/lib/3rdparty/libxml2/error.c b/reactos/sdk/lib/3rdparty/libxml2/error.c index 9c4504055ca..9606f1357e0 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/error.c +++ b/reactos/sdk/lib/3rdparty/libxml2/error.c @@ -18,7 +18,7 @@ void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED, const char *msg, - ...); + ...) LIBXML_ATTR_FORMAT(2,3); #define XML_GET_VAR_STR(msg, str) { \ int size, prev_size = -1; \ @@ -177,8 +177,8 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input , xmlChar content[81]; /* space for 80 chars + line terminator */ xmlChar *ctnt; - if ((input == NULL) || (input->cur == NULL) || - (*input->cur == 0)) return; + if ((input == NULL) || (input->cur == NULL)) + return; cur = input->cur; base = input->base; diff --git a/reactos/sdk/lib/3rdparty/libxml2/libxml.h b/reactos/sdk/lib/3rdparty/libxml2/libxml.h index 66218f0e79f..c3e2748d600 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/libxml.h +++ b/reactos/sdk/lib/3rdparty/libxml2/libxml.h @@ -9,6 +9,8 @@ #ifndef __XML_LIBXML_H__ #define __XML_LIBXML_H__ +#include + #ifndef NO_LARGEFILE_SOURCE #ifndef _LARGEFILE_SOURCE #define _LARGEFILE_SOURCE @@ -68,7 +70,7 @@ extern int __xmlRegisterCallbacks; * internal error reporting routines, shared but not partof the API. */ void __xmlIOErr(int domain, int code, const char *extra); -void __xmlLoaderErr(void *ctx, const char *msg, const char *filename); +void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2,0); #ifdef LIBXML_HTML_ENABLED /* * internal function of HTML parser needed for xmlParseInNodeContext @@ -93,6 +95,7 @@ int __xmlInitializeDict(void); int __xmlRandom(void); #endif +XMLPUBFUN xmlChar * XMLCALL xmlEscapeFormatString(xmlChar **msg); int xmlNop(void); #ifdef IN_LIBXML diff --git a/reactos/sdk/lib/3rdparty/libxml2/parser.c b/reactos/sdk/lib/3rdparty/libxml2/parser.c index c5741e3b8c8..53a6b7f0c96 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/parser.c +++ b/reactos/sdk/lib/3rdparty/libxml2/parser.c @@ -138,14 +138,20 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, * entities problems */ if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && - (ent->content != NULL) && (ent->checked == 0)) { + (ent->content != NULL) && (ent->checked == 0) && + (ctxt->errNo != XML_ERR_ENTITY_LOOP)) { unsigned long oldnbent = ctxt->nbentities; xmlChar *rep; ent->checked = 1; + ++ctxt->depth; rep = xmlStringDecodeEntities(ctxt, ent->content, XML_SUBSTITUTE_REF, 0, 0, 0); + --ctxt->depth; + if (ctxt->errNo == XML_ERR_ENTITY_LOOP) { + ent->content[0] = 0; + } ent->checked = (ctxt->nbentities - oldnbent + 1) * 2; if (rep != NULL) { @@ -344,7 +350,6 @@ static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info) { const char *errmsg; - char errstr[129] = ""; if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) @@ -531,15 +536,17 @@ xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info) default: errmsg = "Unregistered error message"; } - if (info == NULL) - snprintf(errstr, 128, "%s\n", errmsg); - else - snprintf(errstr, 128, "%s: %%s\n", errmsg); if (ctxt != NULL) ctxt->errNo = error; - __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, - XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, &errstr[0], - info); + if (info == NULL) { + __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, + XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s\n", + errmsg); + } else { + __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, + XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s: %s\n", + errmsg, info); + } if (ctxt != NULL) { ctxt->wellFormed = 0; if (ctxt->recovery == 0) @@ -555,7 +562,7 @@ xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info) * * Handle a fatal parser error, i.e. violating Well-Formedness constraints */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg) { @@ -583,7 +590,7 @@ xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a warning. */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, const xmlChar *str2) { @@ -621,7 +628,7 @@ xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a validity error. */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, const xmlChar *str2) { @@ -661,7 +668,7 @@ xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a fatal parser error, i.e. violating Well-Formedness constraints */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, int val) { @@ -691,7 +698,7 @@ xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a fatal parser error, i.e. violating Well-Formedness constraints */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, int val, const xmlChar *str2) @@ -721,7 +728,7 @@ xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a fatal parser error, i.e. violating Well-Formedness constraints */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar * val) { @@ -750,7 +757,7 @@ xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a non fatal parser error */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar * val) { @@ -775,7 +782,7 @@ xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a fatal parser error, i.e. violating Well-Formedness constraints */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar * info1, const xmlChar * info2, @@ -804,7 +811,7 @@ xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, * * Handle a namespace warning error */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlNsWarn(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar * info1, const xmlChar * info2, @@ -2008,6 +2015,7 @@ static int spacePop(xmlParserCtxtPtr ctxt) { #define CUR (*ctxt->input->cur) #define NXT(val) ctxt->input->cur[(val)] #define CUR_PTR ctxt->input->cur +#define BASE_PTR ctxt->input->base #define CMP4( s, c1, c2, c3, c4 ) \ ( ((unsigned char *) s)[ 0 ] == c1 && ((unsigned char *) s)[ 1 ] == c2 && \ @@ -2858,7 +2866,21 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, ctxt->nbentities += ent->checked / 2; if (ent != NULL) { if (ent->content == NULL) { - xmlLoadEntityContent(ctxt, ent); + /* + * Note: external parsed entities will not be loaded, + * it is not required for a non-validating parser to + * complete external PEreferences coming from the + * internal subset + */ + if (((ctxt->options & XML_PARSE_NOENT) != 0) || + ((ctxt->options & XML_PARSE_DTDVALID) != 0) || + (ctxt->validate != 0)) { + xmlLoadEntityContent(ctxt, ent); + } else { + xmlWarningMsg(ctxt, XML_ERR_ENTITY_PROCESSING, + "not validating will not read content for PE entity %s\n", + ent->name, NULL); + } } ctxt->depth++; rep = xmlStringDecodeEntities(ctxt, ent->content, what, @@ -3470,7 +3492,7 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) { int len = 0, l; int c; int count = 0; - const xmlChar *end; /* needed because CUR_CHAR() can move cur on \r\n */ + size_t startPosition = 0; #ifdef DEBUG nbParseNCNameComplex++; @@ -3480,7 +3502,7 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) { * Handler for more complex cases */ GROW; - end = ctxt->input->cur; + startPosition = CUR_PTR - BASE_PTR; c = CUR_CHAR(l); if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */ (!xmlIsNameStartChar(ctxt, c) || (c == ':'))) { @@ -3502,7 +3524,6 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) { } len += l; NEXTL(l); - end = ctxt->input->cur; c = CUR_CHAR(l); if (c == 0) { count = 0; @@ -3516,7 +3537,6 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) { ctxt->input->cur += l; if (ctxt->instate == XML_PARSER_EOF) return(NULL); - end = ctxt->input->cur; c = CUR_CHAR(l); } } @@ -3525,7 +3545,7 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) { xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName"); return(NULL); } - return(xmlDictLookup(ctxt->dict, end - len, len)); + return(xmlDictLookup(ctxt->dict, (BASE_PTR + startPosition), len)); } /** @@ -3625,7 +3645,7 @@ xmlParseNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *other) { } /* failure (or end of input buffer), check with full function */ ret = xmlParseName (ctxt); - /* strings coming from the dictionnary direct compare possible */ + /* strings coming from the dictionary direct compare possible */ if (ret == other) { return (const xmlChar*) 1; } @@ -3966,8 +3986,10 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { * an entity declaration, it is bypassed and left as is. * so XML_SUBSTITUTE_REF is not set here. */ + ++ctxt->depth; ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF, 0, 0, 0); + --ctxt->depth; if (orig != NULL) *orig = buf; else @@ -4092,9 +4114,11 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { } else if ((ent != NULL) && (ctxt->replaceEntities != 0)) { if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) { + ++ctxt->depth; rep = xmlStringDecodeEntities(ctxt, ent->content, XML_SUBSTITUTE_REF, 0, 0, 0); + --ctxt->depth; if (rep != NULL) { current = rep; while (*current != 0) { /* non input consuming */ @@ -4130,8 +4154,10 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { (ent->content != NULL) && (ent->checked == 0)) { unsigned long oldnbent = ctxt->nbentities; + ++ctxt->depth; rep = xmlStringDecodeEntities(ctxt, ent->content, XML_SUBSTITUTE_REF, 0, 0, 0); + --ctxt->depth; ent->checked = (ctxt->nbentities - oldnbent + 1) * 2; if (rep != NULL) { @@ -5501,7 +5527,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) { skipped = SKIP_BLANKS; if (skipped == 0) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, - "Space required after '%'\n"); + "Space required after '%%'\n"); } isParameter = 1; } @@ -6686,6 +6712,7 @@ xmlParseElementDecl(xmlParserCtxtPtr ctxt) { if (!IS_BLANK_CH(CUR)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "Space required after 'ELEMENT'\n"); + return(-1); } SKIP_BLANKS; name = xmlParseName(ctxt); @@ -6837,6 +6864,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) { if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) { xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL); + xmlHaltParser(ctxt); break; } } @@ -8468,6 +8496,7 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) { */ if (RAW != '>') { xmlFatalErr(ctxt, XML_ERR_DOCTYPE_NOT_FINISHED, NULL); + return; } NEXT; } @@ -8818,7 +8847,7 @@ xmlParseEndTag(xmlParserCtxtPtr ctxt) { * @prefix: the prefix to lookup * * Lookup the namespace name for the @prefix (which ca be NULL) - * The prefix must come from the @ctxt->dict dictionnary + * The prefix must come from the @ctxt->dict dictionary * * Returns the namespace name or NULL if not bound */ @@ -9465,7 +9494,10 @@ reparse: else if (nsPush(ctxt, NULL, URL) > 0) nbNs++; skip_default_ns: - if (alloc != 0) xmlFree(attvalue); + if ((attvalue != NULL) && (alloc != 0)) { + xmlFree(attvalue); + attvalue = NULL; + } if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) break; if (!IS_BLANK_CH(RAW)) { @@ -9474,6 +9506,8 @@ skip_default_ns: break; } SKIP_BLANKS; + if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) + goto base_changed; continue; } if (aprefix == ctxt->str_xmlns) { @@ -9545,7 +9579,10 @@ skip_default_ns: else if (nsPush(ctxt, attname, URL) > 0) nbNs++; skip_ns: - if (alloc != 0) xmlFree(attvalue); + if ((attvalue != NULL) && (alloc != 0)) { + xmlFree(attvalue); + attvalue = NULL; + } if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) break; if (!IS_BLANK_CH(RAW)) { @@ -9816,6 +9853,7 @@ static void xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *URI, int line, int nsNr, int tlen) { const xmlChar *name; + size_t curLength; GROW; if ((RAW != '<') || (NXT(1) != '/')) { @@ -9824,8 +9862,11 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix, } SKIP(2); - if ((tlen > 0) && (xmlStrncmp(ctxt->input->cur, ctxt->name, tlen) == 0)) { - if (ctxt->input->cur[tlen] == '>') { + curLength = ctxt->input->end - ctxt->input->cur; + if ((tlen > 0) && (curLength >= (size_t)tlen) && + (xmlStrncmp(ctxt->input->cur, ctxt->name, tlen) == 0)) { + if ((curLength >= (size_t)(tlen + 1)) && + (ctxt->input->cur[tlen] == '>')) { ctxt->input->cur += tlen + 1; ctxt->input->col += tlen + 1; goto done; @@ -11209,8 +11250,9 @@ xmlParseGetLasts(xmlParserCtxtPtr ctxt, const xmlChar **lastlt, } /** * xmlCheckCdataPush: - * @cur: pointer to the bock of characters + * @cur: pointer to the block of characters * @len: length of the block in bytes + * @complete: 1 if complete CDATA block is passed in, 0 if partial block * * Check that the block of characters is okay as SCdata content [20] * @@ -11218,7 +11260,7 @@ xmlParseGetLasts(xmlParserCtxtPtr ctxt, const xmlChar **lastlt, * UTF-8 error occured otherwise */ static int -xmlCheckCdataPush(const xmlChar *utf, int len) { +xmlCheckCdataPush(const xmlChar *utf, int len, int complete) { int ix; unsigned char c; int codepoint; @@ -11236,7 +11278,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) { else return(-ix); } else if ((c & 0xe0) == 0xc0) {/* 2-byte code, starts with 110 */ - if (ix + 2 > len) return(-ix); + if (ix + 2 > len) return(complete ? -ix : ix); if ((utf[ix+1] & 0xc0 ) != 0x80) return(-ix); codepoint = (utf[ix] & 0x1f) << 6; @@ -11245,7 +11287,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) { return(-ix); ix += 2; } else if ((c & 0xf0) == 0xe0) {/* 3-byte code, starts with 1110 */ - if (ix + 3 > len) return(-ix); + if (ix + 3 > len) return(complete ? -ix : ix); if (((utf[ix+1] & 0xc0) != 0x80) || ((utf[ix+2] & 0xc0) != 0x80)) return(-ix); @@ -11256,7 +11298,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) { return(-ix); ix += 3; } else if ((c & 0xf8) == 0xf0) {/* 4-byte code, starts with 11110 */ - if (ix + 4 > len) return(-ix); + if (ix + 4 > len) return(complete ? -ix : ix); if (((utf[ix+1] & 0xc0) != 0x80) || ((utf[ix+2] & 0xc0) != 0x80) || ((utf[ix+3] & 0xc0) != 0x80)) @@ -11771,7 +11813,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { int tmp; tmp = xmlCheckCdataPush(ctxt->input->cur, - XML_PARSER_BIG_BUFFER_SIZE); + XML_PARSER_BIG_BUFFER_SIZE, 0); if (tmp < 0) { tmp = -tmp; ctxt->input->cur += tmp; @@ -11794,7 +11836,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { } else { int tmp; - tmp = xmlCheckCdataPush(ctxt->input->cur, base); + tmp = xmlCheckCdataPush(ctxt->input->cur, base, 1); if ((tmp < 0) || (tmp != base)) { tmp = -tmp; ctxt->input->cur += tmp; @@ -14989,7 +15031,7 @@ xmlCleanupParser(void) { * DICT_FREE: * @str: a string * - * Free a string if it is not owned by the "dict" dictionnary in the + * Free a string if it is not owned by the "dict" dictionary in the * current scope */ #define DICT_FREE(str) \ diff --git a/reactos/sdk/lib/3rdparty/libxml2/parserInternals.c b/reactos/sdk/lib/3rdparty/libxml2/parserInternals.c index 2b8646c2187..bfc778ac1f7 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/parserInternals.c +++ b/reactos/sdk/lib/3rdparty/libxml2/parserInternals.c @@ -55,6 +55,10 @@ #include #include +#define CUR(ctxt) ctxt->input->cur +#define END(ctxt) ctxt->input->end +#define VALID_CTXT(ctxt) (CUR(ctxt) <= END(ctxt)) + #include "buf.h" #include "enc.h" @@ -165,7 +169,7 @@ __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, * * Handle an internal error */ -static void +static void LIBXML_ATTR_FORMAT(2,0) xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str) { if ((ctxt != NULL) && (ctxt->disableSAX != 0) && @@ -193,7 +197,7 @@ xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str) * * n encoding error */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlErrEncodingInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, int val) { @@ -294,7 +298,7 @@ xmlParserInputRead(xmlParserInputPtr in ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUS */ int xmlParserInputGrow(xmlParserInputPtr in, int len) { - size_t ret; + int ret; size_t indx; const xmlChar *content; @@ -422,103 +426,105 @@ xmlNextChar(xmlParserCtxtPtr ctxt) (ctxt->input == NULL)) return; - if (ctxt->charset == XML_CHAR_ENCODING_UTF8) { - if ((*ctxt->input->cur == 0) && - (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0) && - (ctxt->instate != XML_PARSER_COMMENT)) { - /* - * If we are at the end of the current entity and - * the context allows it, we pop consumed entities - * automatically. - * the auto closing should be blocked in other cases - */ + if (!(VALID_CTXT(ctxt))) { + xmlErrInternal(ctxt, "Parser input data memory error\n", NULL); + ctxt->errNo = XML_ERR_INTERNAL_ERROR; + xmlStopParser(ctxt); + return; + } + + if ((*ctxt->input->cur == 0) && + (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) { + if ((ctxt->instate != XML_PARSER_COMMENT)) xmlPopInput(ctxt); - } else { - const unsigned char *cur; - unsigned char c; + return; + } - /* - * 2.11 End-of-Line Handling - * the literal two-character sequence "#xD#xA" or a standalone - * literal #xD, an XML processor must pass to the application - * the single character #xA. - */ - if (*(ctxt->input->cur) == '\n') { - ctxt->input->line++; ctxt->input->col = 1; - } else - ctxt->input->col++; + if (ctxt->charset == XML_CHAR_ENCODING_UTF8) { + const unsigned char *cur; + unsigned char c; - /* - * We are supposed to handle UTF8, check it's valid - * From rfc2044: encoding of the Unicode values on UTF-8: - * - * UCS-4 range (hex.) UTF-8 octet sequence (binary) - * 0000 0000-0000 007F 0xxxxxxx - * 0000 0080-0000 07FF 110xxxxx 10xxxxxx - * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx - * - * Check for the 0x110000 limit too - */ - cur = ctxt->input->cur; + /* + * 2.11 End-of-Line Handling + * the literal two-character sequence "#xD#xA" or a standalone + * literal #xD, an XML processor must pass to the application + * the single character #xA. + */ + if (*(ctxt->input->cur) == '\n') { + ctxt->input->line++; ctxt->input->col = 1; + } else + ctxt->input->col++; - c = *cur; - if (c & 0x80) { - if (c == 0xC0) - goto encoding_error; - if (cur[1] == 0) { + /* + * We are supposed to handle UTF8, check it's valid + * From rfc2044: encoding of the Unicode values on UTF-8: + * + * UCS-4 range (hex.) UTF-8 octet sequence (binary) + * 0000 0000-0000 007F 0xxxxxxx + * 0000 0080-0000 07FF 110xxxxx 10xxxxxx + * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx + * + * Check for the 0x110000 limit too + */ + cur = ctxt->input->cur; + + c = *cur; + if (c & 0x80) { + if (c == 0xC0) + goto encoding_error; + if (cur[1] == 0) { + xmlParserInputGrow(ctxt->input, INPUT_CHUNK); + cur = ctxt->input->cur; + } + if ((cur[1] & 0xc0) != 0x80) + goto encoding_error; + if ((c & 0xe0) == 0xe0) { + unsigned int val; + + if (cur[2] == 0) { xmlParserInputGrow(ctxt->input, INPUT_CHUNK); cur = ctxt->input->cur; } - if ((cur[1] & 0xc0) != 0x80) + if ((cur[2] & 0xc0) != 0x80) goto encoding_error; - if ((c & 0xe0) == 0xe0) { - unsigned int val; - - if (cur[2] == 0) { + if ((c & 0xf0) == 0xf0) { + if (cur[3] == 0) { xmlParserInputGrow(ctxt->input, INPUT_CHUNK); cur = ctxt->input->cur; } - if ((cur[2] & 0xc0) != 0x80) + if (((c & 0xf8) != 0xf0) || + ((cur[3] & 0xc0) != 0x80)) goto encoding_error; - if ((c & 0xf0) == 0xf0) { - if (cur[3] == 0) { - xmlParserInputGrow(ctxt->input, INPUT_CHUNK); - cur = ctxt->input->cur; - } - if (((c & 0xf8) != 0xf0) || - ((cur[3] & 0xc0) != 0x80)) - goto encoding_error; - /* 4-byte code */ - ctxt->input->cur += 4; - val = (cur[0] & 0x7) << 18; - val |= (cur[1] & 0x3f) << 12; - val |= (cur[2] & 0x3f) << 6; - val |= cur[3] & 0x3f; - } else { - /* 3-byte code */ - ctxt->input->cur += 3; - val = (cur[0] & 0xf) << 12; - val |= (cur[1] & 0x3f) << 6; - val |= cur[2] & 0x3f; - } - if (((val > 0xd7ff) && (val < 0xe000)) || - ((val > 0xfffd) && (val < 0x10000)) || - (val >= 0x110000)) { - xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR, - "Char 0x%X out of allowed range\n", - val); - } - } else - /* 2-byte code */ - ctxt->input->cur += 2; + /* 4-byte code */ + ctxt->input->cur += 4; + val = (cur[0] & 0x7) << 18; + val |= (cur[1] & 0x3f) << 12; + val |= (cur[2] & 0x3f) << 6; + val |= cur[3] & 0x3f; + } else { + /* 3-byte code */ + ctxt->input->cur += 3; + val = (cur[0] & 0xf) << 12; + val |= (cur[1] & 0x3f) << 6; + val |= cur[2] & 0x3f; + } + if (((val > 0xd7ff) && (val < 0xe000)) || + ((val > 0xfffd) && (val < 0x10000)) || + (val >= 0x110000)) { + xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR, + "Char 0x%X out of allowed range\n", + val); + } } else - /* 1-byte code */ - ctxt->input->cur++; + /* 2-byte code */ + ctxt->input->cur += 2; + } else + /* 1-byte code */ + ctxt->input->cur++; - ctxt->nbChars++; - if (*ctxt->input->cur == 0) - xmlParserInputGrow(ctxt->input, INPUT_CHUNK); - } + ctxt->nbChars++; + if (*ctxt->input->cur == 0) + xmlParserInputGrow(ctxt->input, INPUT_CHUNK); } else { /* * Assume it's a fixed length encoding (1) with diff --git a/reactos/sdk/lib/3rdparty/libxml2/relaxng.c b/reactos/sdk/lib/3rdparty/libxml2/relaxng.c index 5779e7fc5f4..56a3344a2fe 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/relaxng.c +++ b/reactos/sdk/lib/3rdparty/libxml2/relaxng.c @@ -507,7 +507,7 @@ xmlRngVErrMemory(xmlRelaxNGValidCtxtPtr ctxt, const char *extra) * * Handle a Relax NG Parsing error */ -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlRngPErr(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar * str1, const xmlChar * str2) { @@ -541,7 +541,7 @@ xmlRngPErr(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, int error, * * Handle a Relax NG Validation error */ -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlRngVErr(xmlRelaxNGValidCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar * str1, const xmlChar * str2) { @@ -2215,7 +2215,8 @@ xmlRelaxNGGetErrorString(xmlRelaxNGValidErr err, const xmlChar * arg1, snprintf(msg, 1000, "Unknown error code %d\n", err); } msg[1000 - 1] = 0; - return (xmlStrdup((xmlChar *) msg)); + xmlChar *result = xmlCharStrdup(msg); + return (xmlEscapeFormatString(&result)); } /** diff --git a/reactos/sdk/lib/3rdparty/libxml2/schematron.c b/reactos/sdk/lib/3rdparty/libxml2/schematron.c index eb4befebfc3..6200f2d4130 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/schematron.c +++ b/reactos/sdk/lib/3rdparty/libxml2/schematron.c @@ -133,7 +133,7 @@ struct _xmlSchematron { int flags; /* specific to this schematron */ void *_private; /* unused by the library */ - xmlDictPtr dict; /* the dictionnary used internally */ + xmlDictPtr dict; /* the dictionary used internally */ const xmlChar *title; /* the title if any */ @@ -186,7 +186,7 @@ struct _xmlSchematronParserCtxt { const char *buffer; int size; - xmlDictPtr dict; /* dictionnary for interned string names */ + xmlDictPtr dict; /* dictionary for interned string names */ int nberrors; int err; @@ -245,7 +245,7 @@ xmlSchematronPErrMemory(xmlSchematronParserCtxtPtr ctxt, * * Handle a parser error */ -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlSchematronPErr(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar * str1, const xmlChar * str2) { diff --git a/reactos/sdk/lib/3rdparty/libxml2/tree.c b/reactos/sdk/lib/3rdparty/libxml2/tree.c index 6a158cec335..9d330b85cd3 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/tree.c +++ b/reactos/sdk/lib/3rdparty/libxml2/tree.c @@ -1044,7 +1044,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name, * DICT_FREE: * @str: a string * - * Free a string if it is not owned by the "dict" dictionnary in the + * Free a string if it is not owned by the "dict" dictionary in the * current scope */ #define DICT_FREE(str) \ @@ -1057,7 +1057,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name, * DICT_COPY: * @str: a string * - * Copy a string using a "dict" dictionnary in the current scope, + * Copy a string using a "dict" dictionary in the current scope, * if availabe. */ #define DICT_COPY(str, cpy) \ @@ -1074,7 +1074,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name, * DICT_CONST_COPY: * @str: a string * - * Copy a string using a "dict" dictionnary in the current scope, + * Copy a string using a "dict" dictionary in the current scope, * if availabe. */ #define DICT_CONST_COPY(str, cpy) \ @@ -1593,6 +1593,7 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) { else if ((ent != NULL) && (ent->children == NULL)) { xmlNodePtr temp; + ent->children = (xmlNodePtr) -1; ent->children = xmlStringGetNodeList(doc, (const xmlChar*)node->content); ent->owner = 1; @@ -2270,7 +2271,7 @@ xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) { cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); if (cur == NULL) { xmlTreeErrMemory("building node"); - /* we can't check here that name comes from the doc dictionnary */ + /* we can't check here that name comes from the doc dictionary */ return(NULL); } memset(cur, 0, sizeof(xmlNode)); @@ -2350,7 +2351,7 @@ xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns, UPDATE_LAST_CHILD_AND_PARENT(cur) } } else { - /* if name don't come from the doc dictionnary free it here */ + /* if name don't come from the doc dictionary free it here */ if ((name != NULL) && (doc != NULL) && (!(xmlDictOwns(doc->dict, name)))) xmlFree(name); @@ -3701,7 +3702,7 @@ xmlFreeNodeList(xmlNodePtr cur) { * When a node is a text node or a comment, it uses a global static * variable for the name of the node. * Otherwise the node name might come from the document's - * dictionnary + * dictionary */ if ((cur->name != NULL) && (cur->type != XML_TEXT_NODE) && @@ -3770,7 +3771,7 @@ xmlFreeNode(xmlNodePtr cur) { /* * When a node is a text node or a comment, it uses a global static * variable for the name of the node. - * Otherwise the node name might come from the document's dictionnary + * Otherwise the node name might come from the document's dictionary */ if ((cur->name != NULL) && (cur->type != XML_TEXT_NODE) && diff --git a/reactos/sdk/lib/3rdparty/libxml2/uri.c b/reactos/sdk/lib/3rdparty/libxml2/uri.c index ff47abbecb1..2bd5720de97 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/uri.c +++ b/reactos/sdk/lib/3rdparty/libxml2/uri.c @@ -314,7 +314,7 @@ xmlParse3986Query(xmlURIPtr uri, const char **str) * @uri: pointer to an URI structure * @str: the string to analyze * - * Parse a port part and fills in the appropriate fields + * Parse a port part and fills in the appropriate fields * of the @uri structure * * port = *DIGIT @@ -325,15 +325,16 @@ static int xmlParse3986Port(xmlURIPtr uri, const char **str) { const char *cur = *str; + unsigned port = 0; /* unsigned for defined overflow behavior */ if (ISA_DIGIT(cur)) { - if (uri != NULL) - uri->port = 0; while (ISA_DIGIT(cur)) { - if (uri != NULL) - uri->port = uri->port * 10 + (*cur - '0'); + port = port * 10 + (*cur - '0'); + cur++; } + if (uri != NULL) + uri->port = port & INT_MAX; /* port value modulo INT_MAX+1 */ *str = cur; return(0); } diff --git a/reactos/sdk/lib/3rdparty/libxml2/valid.c b/reactos/sdk/lib/3rdparty/libxml2/valid.c index 45a3f703a24..19f84b82623 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/valid.c +++ b/reactos/sdk/lib/3rdparty/libxml2/valid.c @@ -93,7 +93,7 @@ xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra) * * Handle a validation error */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error, const char *msg, const char *extra) { @@ -137,7 +137,7 @@ xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error, * * Handle a validation error, provide contextual informations */ -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlErrValidNode(xmlValidCtxtPtr ctxt, xmlNodePtr node, xmlParserErrors error, const char *msg, const xmlChar * str1, @@ -180,7 +180,7 @@ xmlErrValidNode(xmlValidCtxtPtr ctxt, * * Handle a validation error, provide contextual informations */ -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlErrValidNodeNr(xmlValidCtxtPtr ctxt, xmlNodePtr node, xmlParserErrors error, const char *msg, const xmlChar * str1, @@ -221,7 +221,7 @@ xmlErrValidNodeNr(xmlValidCtxtPtr ctxt, * * Handle a validation error, provide contextual information */ -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlErrValidWarning(xmlValidCtxtPtr ctxt, xmlNodePtr node, xmlParserErrors error, const char *msg, const xmlChar * str1, @@ -2532,7 +2532,7 @@ xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) { * DICT_FREE: * @str: a string * - * Free a string if it is not owned by the "dict" dictionnary in the + * Free a string if it is not owned by the "dict" dictionary in the * current scope */ #define DICT_FREE(str) \ diff --git a/reactos/sdk/lib/3rdparty/libxml2/xinclude.c b/reactos/sdk/lib/3rdparty/libxml2/xinclude.c index ff3dafbb986..e3bb43ec502 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xinclude.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xinclude.c @@ -125,7 +125,7 @@ xmlXIncludeErrMemory(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, * * Handle an XInclude error */ -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlXIncludeErr(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar *extra) { @@ -147,7 +147,7 @@ xmlXIncludeErr(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error, * * Emit an XInclude warning. */ -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlXIncludeWarn(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar *extra) { diff --git a/reactos/sdk/lib/3rdparty/libxml2/xmlIO.c b/reactos/sdk/lib/3rdparty/libxml2/xmlIO.c index 069b4255169..309f48a484b 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xmlIO.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xmlIO.c @@ -1605,7 +1605,7 @@ xmlCreateZMemBuff( int compression ) { xmlFreeZMemBuff( buff ); buff = NULL; xmlStrPrintf(msg, 500, - (const xmlChar *) "xmlCreateZMemBuff: %s %d\n", + "xmlCreateZMemBuff: %s %d\n", "Error initializing compression context. ZLIB error:", z_err ); xmlIOErr(XML_IO_WRITE, (const char *) msg); @@ -1673,7 +1673,7 @@ xmlZMemBuffExtend( xmlZMemBuffPtr buff, size_t ext_amt ) { else { xmlChar msg[500]; xmlStrPrintf(msg, 500, - (const xmlChar *) "xmlZMemBuffExtend: %s %lu bytes.\n", + "xmlZMemBuffExtend: %s %lu bytes.\n", "Allocation failure extending output buffer to", new_size ); xmlIOErr(XML_IO_WRITE, (const char *) msg); @@ -1719,7 +1719,7 @@ xmlZMemBuffAppend( xmlZMemBuffPtr buff, const char * src, int len ) { if ( z_err != Z_OK ) { xmlChar msg[500]; xmlStrPrintf(msg, 500, - (const xmlChar *) "xmlZMemBuffAppend: %s %d %s - %d", + "xmlZMemBuffAppend: %s %d %s - %d", "Compression error while appending", len, "bytes to buffer. ZLIB error", z_err ); xmlIOErr(XML_IO_WRITE, (const char *) msg); @@ -1792,7 +1792,7 @@ xmlZMemBuffGetContent( xmlZMemBuffPtr buff, char ** data_ref ) { else { xmlChar msg[500]; xmlStrPrintf(msg, 500, - (const xmlChar *) "xmlZMemBuffGetContent: %s - %d\n", + "xmlZMemBuffGetContent: %s - %d\n", "Error flushing zlib buffers. Error code", z_err ); xmlIOErr(XML_IO_WRITE, (const char *) msg); } @@ -1997,7 +1997,7 @@ xmlIOHTTPWrite( void * context, const char * buffer, int len ) { if ( len < 0 ) { xmlChar msg[500]; xmlStrPrintf(msg, 500, - (const xmlChar *) "xmlIOHTTPWrite: %s\n%s '%s'.\n", + "xmlIOHTTPWrite: %s\n%s '%s'.\n", "Error appending to internal buffer.", "Error sending document to URI", ctxt->uri ); @@ -2069,7 +2069,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) { if ( http_content == NULL ) { xmlChar msg[500]; xmlStrPrintf(msg, 500, - (const xmlChar *) "xmlIOHTTPCloseWrite: %s '%s' %s '%s'.\n", + "xmlIOHTTPCloseWrite: %s '%s' %s '%s'.\n", "Error retrieving content.\nUnable to", http_mthd, "data to URI", ctxt->uri ); xmlIOErr(XML_IO_WRITE, (const char *) msg); @@ -2141,7 +2141,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) { else { xmlChar msg[500]; xmlStrPrintf(msg, 500, - (const xmlChar *) "xmlIOHTTPCloseWrite: HTTP '%s' of %d %s\n'%s' %s %d\n", + "xmlIOHTTPCloseWrite: HTTP '%s' of %d %s\n'%s' %s %d\n", http_mthd, content_lgth, "bytes to URI", ctxt->uri, "failed. HTTP return code:", http_rtn ); diff --git a/reactos/sdk/lib/3rdparty/libxml2/xmlcatalog.c b/reactos/sdk/lib/3rdparty/libxml2/xmlcatalog.c index b9ed6a488bd..006f0cc94c9 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xmlcatalog.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xmlcatalog.c @@ -80,6 +80,7 @@ xmlShellReadline(const char *prompt) { if (prompt != NULL) fprintf(stdout, "%s", prompt); + fflush(stdout); if (!fgets(line_read, 500, stdin)) return(NULL); line_read[500] = 0; diff --git a/reactos/sdk/lib/3rdparty/libxml2/xmllint.c b/reactos/sdk/lib/3rdparty/libxml2/xmllint.c index 1e2eb4ab74f..67f7adb2340 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xmllint.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xmllint.c @@ -449,7 +449,7 @@ startTimer(void) * message about the timing performed; format is a printf * type argument */ -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(1,2) endTimer(const char *fmt, ...) { long msec; @@ -485,7 +485,7 @@ startTimer(void) { begin = clock(); } -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(1,2) endTimer(const char *fmt, ...) { long msec; @@ -514,7 +514,7 @@ startTimer(void) * Do nothing */ } -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(1,2) endTimer(char *format, ...) { /* @@ -634,7 +634,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) { * Display and format an error messages, gives file, line, position and * extra parameters. */ -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(2,3) xmlHTMLError(void *ctx, const char *msg, ...) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; @@ -671,7 +671,7 @@ xmlHTMLError(void *ctx, const char *msg, ...) * Display and format a warning messages, gives file, line, position and * extra parameters. */ -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(2,3) xmlHTMLWarning(void *ctx, const char *msg, ...) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; @@ -709,7 +709,7 @@ xmlHTMLWarning(void *ctx, const char *msg, ...) * Display and format an validity error messages, gives file, * line, position and extra parameters. */ -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(2,3) xmlHTMLValidityError(void *ctx, const char *msg, ...) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; @@ -746,7 +746,7 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...) * Display and format a validity warning messages, gives file, line, * position and extra parameters. */ -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(2,3) xmlHTMLValidityWarning(void *ctx, const char *msg, ...) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; @@ -809,6 +809,7 @@ xmlShellReadline(char *prompt) { if (prompt != NULL) fprintf(stdout, "%s", prompt); + fflush(stdout); if (!fgets(line_read, 500, stdin)) return(NULL); line_read[500] = 0; @@ -1410,7 +1411,7 @@ commentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value) * Display and format a warning messages, gives file, line, position and * extra parameters. */ -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(2,3) warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { va_list args; @@ -1433,7 +1434,7 @@ warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) * Display and format a error messages, gives file, line, position and * extra parameters. */ -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(2,3) errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { va_list args; @@ -1456,7 +1457,7 @@ errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) * Display and format a fatalError messages, gives file, line, position and * extra parameters. */ -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(2,3) fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { va_list args; @@ -2001,6 +2002,12 @@ static void walkDoc(xmlDocPtr doc) { xmlNsPtr ns; root = xmlDocGetRootElement(doc); + if (root == NULL ) { + xmlGenericError(xmlGenericErrorContext, + "Document does not have a root element"); + progresult = XMLLINT_ERR_UNCLASS; + return; + } for (ns = root->nsDef, i = 0;ns != NULL && i < 20;ns=ns->next) { namespaces[i++] = ns->href; namespaces[i++] = ns->prefix; @@ -2967,6 +2974,7 @@ static void showVersion(const char *name) { if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer "); if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude "); if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv "); + if (xmlHasFeature(XML_WITH_ICU)) fprintf(stderr, "ICU "); if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X "); if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode "); if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps "); diff --git a/reactos/sdk/lib/3rdparty/libxml2/xmlmemory.c b/reactos/sdk/lib/3rdparty/libxml2/xmlmemory.c index f24fd6d4fff..f08c8c3d3bb 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xmlmemory.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xmlmemory.c @@ -109,6 +109,7 @@ typedef struct memnod { #define RESERVE_SIZE (((HDR_SIZE + (ALIGN_SIZE-1)) \ / ALIGN_SIZE ) * ALIGN_SIZE) +#define MAX_SIZE_T ((size_t)-1) #define CLIENT_2_HDR(a) ((MEMHDR *) (((char *) (a)) - RESERVE_SIZE)) #define HDR_2_CLIENT(a) ((void *) (((char *) (a)) + RESERVE_SIZE)) @@ -217,7 +218,7 @@ xmlMallocLoc(size_t size, const char * file, int line) /** * xmlMallocAtomicLoc: - * @size: an int specifying the size in byte to allocate. + * @size: an unsigned int specifying the size in byte to allocate. * @file: the file name or NULL * @line: the line number * @@ -240,11 +241,18 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line) TEST_POINT + if (size > (MAX_SIZE_T - RESERVE_SIZE)) { + xmlGenericError(xmlGenericErrorContext, + "xmlMallocAtomicLoc : Unsigned overflow prevented\n"); + xmlMemoryDump(); + return(NULL); + } + p = (MEMHDR *) malloc(RESERVE_SIZE+size); if (!p) { xmlGenericError(xmlGenericErrorContext, - "xmlMallocLoc : Out of free space\n"); + "xmlMallocAtomicLoc : Out of free space\n"); xmlMemoryDump(); return(NULL); } diff --git a/reactos/sdk/lib/3rdparty/libxml2/xmlreader.c b/reactos/sdk/lib/3rdparty/libxml2/xmlreader.c index 471e7e2a640..f285790be21 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xmlreader.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xmlreader.c @@ -142,7 +142,7 @@ struct _xmlTextReader { xmlNodePtr faketext;/* fake xmlNs chld */ int preserve;/* preserve the resulting document */ xmlBufPtr buffer; /* used to return const xmlChar * */ - xmlDictPtr dict; /* the context dictionnary */ + xmlDictPtr dict; /* the context dictionary */ /* entity stack when traversing entities content */ xmlNodePtr ent; /* Current Entity Ref Node */ @@ -210,7 +210,7 @@ static int xmlTextReaderNextTree(xmlTextReaderPtr reader); * DICT_FREE: * @str: a string * - * Free a string if it is not owned by the "dict" dictionnary in the + * Free a string if it is not owned by the "dict" dictionary in the * current scope */ #define DICT_FREE(str) \ @@ -2158,7 +2158,7 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) { ret->ctxt->dictNames = 1; ret->allocs = XML_TEXTREADER_CTXT; /* - * use the parser dictionnary to allocate all elements and attributes names + * use the parser dictionary to allocate all elements and attributes names */ ret->ctxt->docdict = 1; ret->dict = ret->ctxt->dict; @@ -4050,13 +4050,19 @@ xmlTextReaderCurrentDoc(xmlTextReaderPtr reader) { } #ifdef LIBXML_SCHEMAS_ENABLED -static char *xmlTextReaderBuildMessage(const char *msg, va_list ap); +static char *xmlTextReaderBuildMessage(const char *msg, va_list ap) LIBXML_ATTR_FORMAT(1,0); static void XMLCDECL -xmlTextReaderValidityError(void *ctxt, const char *msg, ...); +xmlTextReaderValidityError(void *ctxt, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); static void XMLCDECL -xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...); +xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); + +static void XMLCDECL +xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); + +static void XMLCDECL +xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); static void XMLCDECL xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...) @@ -4850,7 +4856,7 @@ xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error) } } -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(2,3) xmlTextReaderError(void *ctxt, const char *msg, ...) { va_list ap; @@ -4863,7 +4869,7 @@ xmlTextReaderError(void *ctxt, const char *msg, ...) } -static void XMLCDECL +static void XMLCDECL LIBXML_ATTR_FORMAT(2,3) xmlTextReaderWarning(void *ctxt, const char *msg, ...) { va_list ap; @@ -5249,7 +5255,7 @@ xmlTextReaderSetup(xmlTextReaderPtr reader, reader->ctxt->linenumbers = 1; reader->ctxt->dictNames = 1; /* - * use the parser dictionnary to allocate all elements and attributes names + * use the parser dictionary to allocate all elements and attributes names */ reader->ctxt->docdict = 1; reader->ctxt->parseMode = XML_PARSE_READER; diff --git a/reactos/sdk/lib/3rdparty/libxml2/xmlregexp.c b/reactos/sdk/lib/3rdparty/libxml2/xmlregexp.c index 3e912ab92e8..ca3b4f46dc8 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xmlregexp.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xmlregexp.c @@ -1544,6 +1544,7 @@ static int xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, xmlRegStatePtr to, xmlRegAtomPtr atom) { xmlRegStatePtr end; + int nullable = 0; if (atom == NULL) { ERROR("genrate transition: atom == NULL"); @@ -1730,6 +1731,13 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, if (xmlRegAtomPush(ctxt, atom) < 0) { return(-1); } + if ((atom->quant == XML_REGEXP_QUANT_RANGE) && + (atom->min == 0) && (atom->max > 0)) { + nullable = 1; + atom->min = 1; + if (atom->max == 1) + atom->quant = XML_REGEXP_QUANT_OPT; + } xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1); ctxt->state = end; switch (atom->quant) { @@ -1747,11 +1755,8 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1); break; case XML_REGEXP_QUANT_RANGE: -#if DV_test - if (atom->min == 0) { + if (nullable) xmlFAGenerateEpsilonTransition(ctxt, from, to); - } -#endif break; default: break; @@ -5052,11 +5057,12 @@ xmlFAParseCharRange(xmlRegParserCtxtPtr ctxt) { ERROR("Expecting the end of a char range"); return; } - NEXTL(len); + /* TODO check that the values are acceptable character ranges for XML */ if (end < start) { ERROR("End of range is before start of range"); } else { + NEXTL(len); xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, XML_REGEXP_CHARVAL, start, end, NULL); } @@ -6345,7 +6351,7 @@ struct _xmlExpCtxt { /** * xmlExpNewCtxt: * @maxNodes: the maximum number of nodes - * @dict: optional dictionnary to use internally + * @dict: optional dictionary to use internally * * Creates a new context for manipulating expressions * @@ -7204,7 +7210,7 @@ xmlExpStringDerive(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, return(NULL); } /* - * check the string is in the dictionnary, if yes use an interned + * check the string is in the dictionary, if yes use an interned * copy, otherwise we know it's not an acceptable input */ input = xmlDictExists(ctxt->dict, str, len); diff --git a/reactos/sdk/lib/3rdparty/libxml2/xmlsave.c b/reactos/sdk/lib/3rdparty/libxml2/xmlsave.c index 774404b884a..4a8e3f39032 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xmlsave.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xmlsave.c @@ -2097,8 +2097,8 @@ xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc, xmlBufAdd(buf, BAD_CAST "&", 5); cur++; base = cur; - } else if ((*cur >= 0x80) && ((doc == NULL) || - (doc->encoding == NULL))) { + } else if ((*cur >= 0x80) && (cur[1] != 0) && + ((doc == NULL) || (doc->encoding == NULL))) { /* * We assume we have UTF-8 content. */ @@ -2121,14 +2121,14 @@ xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc, val <<= 6; val |= (cur[1]) & 0x3F; l = 2; - } else if (*cur < 0xF0) { + } else if ((*cur < 0xF0) && (cur [2] != 0)) { val = (cur[0]) & 0x0F; val <<= 6; val |= (cur[1]) & 0x3F; val <<= 6; val |= (cur[2]) & 0x3F; l = 3; - } else if (*cur < 0xF8) { + } else if ((*cur < 0xF8) && (cur [2] != 0) && (cur[3] != 0)) { val = (cur[0]) & 0x07; val <<= 6; val |= (cur[1]) & 0x3F; diff --git a/reactos/sdk/lib/3rdparty/libxml2/xmlschemas.c b/reactos/sdk/lib/3rdparty/libxml2/xmlschemas.c index fe533e6f65e..e1b3a4f0386 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xmlschemas.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xmlschemas.c @@ -617,7 +617,7 @@ struct _xmlSchemaParserCtxt { xmlAutomataStatePtr end; xmlAutomataStatePtr state; - xmlDictPtr dict; /* dictionnary for interned string names */ + xmlDictPtr dict; /* dictionary for interned string names */ xmlSchemaTypePtr ctxtType; /* The current context simple/complex type */ int options; xmlSchemaValidCtxtPtr vctxt; @@ -1085,7 +1085,7 @@ xmlSchemaGetUnionSimpleTypeMemberTypes(xmlSchemaTypePtr type); static void xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt, const char *funcName, - const char *message); + const char *message) LIBXML_ATTR_FORMAT(3,0); static int xmlSchemaCheckCOSSTDerivedOK(xmlSchemaAbstractCtxtPtr ctxt, xmlSchemaTypePtr type, @@ -1769,7 +1769,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf, } FREE_AND_NULL(str) - return (*buf); + return (xmlEscapeFormatString(buf)); } /** @@ -1889,7 +1889,7 @@ xmlSchemaPErrMemory(xmlSchemaParserCtxtPtr ctxt, * * Handle a parser error */ -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar * str1, const xmlChar * str2) { @@ -1922,7 +1922,7 @@ xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, * * Handle a parser error */ -static void +static void LIBXML_ATTR_FORMAT(5,0) xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, xmlNodePtr child, int error, const char *msg, const xmlChar * str1, const xmlChar * str2) @@ -1951,7 +1951,7 @@ xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, * * Handle a parser error */ -static void +static void LIBXML_ATTR_FORMAT(7,0) xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, const xmlChar * strData1, const xmlChar * strData2, const xmlChar * strData3, const char *msg, const xmlChar * str1, @@ -2002,7 +2002,7 @@ xmlSchemaVErrMemory(xmlSchemaValidCtxtPtr ctxt, extra); } -static void +static void LIBXML_ATTR_FORMAT(2,0) xmlSchemaPSimpleInternalErr(xmlNodePtr node, const char *msg, const xmlChar *str) { @@ -2013,18 +2013,21 @@ xmlSchemaPSimpleInternalErr(xmlNodePtr node, #define WXS_ERROR_TYPE_ERROR 1 #define WXS_ERROR_TYPE_WARNING 2 /** - * xmlSchemaErr3: + * xmlSchemaErr4Line: * @ctxt: the validation context - * @node: the context node + * @errorLevel: the error level * @error: the error code + * @node: the context node + * @line: the line number * @msg: the error message * @str1: extra data * @str2: extra data * @str3: extra data + * @str4: extra data * * Handle a validation error */ -static void +static void LIBXML_ATTR_FORMAT(6,0) xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt, xmlErrorLevel errorLevel, int error, xmlNodePtr node, int line, const char *msg, @@ -2139,7 +2142,7 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt, * * Handle a validation error */ -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt, int error, xmlNodePtr node, const char *msg, const xmlChar *str1, const xmlChar *str2, const xmlChar *str3) @@ -2148,7 +2151,7 @@ xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt, msg, str1, str2, str3, NULL); } -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt, int error, xmlNodePtr node, const char *msg, const xmlChar *str1, const xmlChar *str2, @@ -2158,7 +2161,7 @@ xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt, msg, str1, str2, str3, str4); } -static void +static void LIBXML_ATTR_FORMAT(4,0) xmlSchemaErr(xmlSchemaAbstractCtxtPtr actxt, int error, xmlNodePtr node, const char *msg, const xmlChar *str1, const xmlChar *str2) @@ -2181,7 +2184,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg, /* * Don't try to format other nodes than element and * attribute nodes. - * Play save and return an empty string. + * Play safe and return an empty string. */ *msg = xmlStrdup(BAD_CAST ""); return(*msg); @@ -2246,6 +2249,13 @@ xmlSchemaFormatNodeForError(xmlChar ** msg, TODO return (NULL); } + + /* + * xmlSchemaFormatItemForReport() also returns an escaped format + * string, so do this before calling it below (in the future). + */ + xmlEscapeFormatString(msg); + /* * VAL TODO: The output of the given schema component is currently * disabled. @@ -2262,7 +2272,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg, return (*msg); } -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt, const char *funcName, const char *message, @@ -2273,24 +2283,21 @@ xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt, if (actxt == NULL) return; - msg = xmlStrdup(BAD_CAST "Internal error: "); - msg = xmlStrcat(msg, BAD_CAST funcName); - msg = xmlStrcat(msg, BAD_CAST ", "); + msg = xmlStrdup(BAD_CAST "Internal error: %s, "); msg = xmlStrcat(msg, BAD_CAST message); msg = xmlStrcat(msg, BAD_CAST ".\n"); if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) - xmlSchemaErr(actxt, XML_SCHEMAV_INTERNAL, NULL, - (const char *) msg, str1, str2); - + xmlSchemaErr3(actxt, XML_SCHEMAV_INTERNAL, NULL, + (const char *) msg, (const xmlChar *) funcName, str1, str2); else if (actxt->type == XML_SCHEMA_CTXT_PARSER) - xmlSchemaErr(actxt, XML_SCHEMAP_INTERNAL, NULL, - (const char *) msg, str1, str2); + xmlSchemaErr3(actxt, XML_SCHEMAP_INTERNAL, NULL, + (const char *) msg, (const xmlChar *) funcName, str1, str2); FREE_AND_NULL(msg) } -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt, const char *funcName, const char *message) @@ -2299,7 +2306,7 @@ xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt, } #if 0 -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlSchemaPInternalErr(xmlSchemaParserCtxtPtr pctxt, const char *funcName, const char *message, @@ -2311,7 +2318,7 @@ xmlSchemaPInternalErr(xmlSchemaParserCtxtPtr pctxt, } #endif -static void +static void LIBXML_ATTR_FORMAT(5,0) xmlSchemaCustomErr4(xmlSchemaAbstractCtxtPtr actxt, xmlParserErrors error, xmlNodePtr node, @@ -2336,7 +2343,7 @@ xmlSchemaCustomErr4(xmlSchemaAbstractCtxtPtr actxt, FREE_AND_NULL(msg) } -static void +static void LIBXML_ATTR_FORMAT(5,0) xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt, xmlParserErrors error, xmlNodePtr node, @@ -2351,7 +2358,7 @@ xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt, -static void +static void LIBXML_ATTR_FORMAT(5,0) xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt, xmlParserErrors error, xmlNodePtr node, @@ -2376,7 +2383,7 @@ xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt, -static void +static void LIBXML_ATTR_FORMAT(5,0) xmlSchemaKeyrefErr(xmlSchemaValidCtxtPtr vctxt, xmlParserErrors error, xmlSchemaPSVIIDCNodePtr idcNode, @@ -2476,11 +2483,13 @@ xmlSchemaSimpleTypeErr(xmlSchemaAbstractCtxtPtr actxt, msg = xmlStrcat(msg, BAD_CAST " '"); if (type->builtInType != 0) { msg = xmlStrcat(msg, BAD_CAST "xs:"); - msg = xmlStrcat(msg, type->name); - } else - msg = xmlStrcat(msg, - xmlSchemaFormatQName(&str, - type->targetNamespace, type->name)); + str = xmlStrdup(type->name); + } else { + const xmlChar *qName = xmlSchemaFormatQName(&str, type->targetNamespace, type->name); + if (!str) + str = xmlStrdup(qName); + } + msg = xmlStrcat(msg, xmlEscapeFormatString(&str)); msg = xmlStrcat(msg, BAD_CAST "'"); FREE_AND_NULL(str); } @@ -2525,7 +2534,7 @@ xmlSchemaIllegalAttrErr(xmlSchemaAbstractCtxtPtr actxt, FREE_AND_NULL(msg) } -static void +static void LIBXML_ATTR_FORMAT(5,0) xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, xmlParserErrors error, xmlNodePtr node, @@ -2617,7 +2626,7 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, str = xmlStrcat(str, BAD_CAST ", "); } str = xmlStrcat(str, BAD_CAST " ).\n"); - msg = xmlStrcat(msg, BAD_CAST str); + msg = xmlStrcat(msg, xmlEscapeFormatString(&str)); FREE_AND_NULL(str) } else msg = xmlStrcat(msg, BAD_CAST "\n"); @@ -2625,7 +2634,7 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, xmlFree(msg); } -static void +static void LIBXML_ATTR_FORMAT(8,0) xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt, xmlParserErrors error, xmlNodePtr node, @@ -2916,7 +2925,7 @@ xmlSchemaPIllegalAttrErr(xmlSchemaParserCtxtPtr ctxt, * * Reports an error during parsing. */ -static void +static void LIBXML_ATTR_FORMAT(5,0) xmlSchemaPCustomErrExt(xmlSchemaParserCtxtPtr ctxt, xmlParserErrors error, xmlSchemaBasicItemPtr item, @@ -2952,7 +2961,7 @@ xmlSchemaPCustomErrExt(xmlSchemaParserCtxtPtr ctxt, * * Reports an error during parsing. */ -static void +static void LIBXML_ATTR_FORMAT(5,0) xmlSchemaPCustomErr(xmlSchemaParserCtxtPtr ctxt, xmlParserErrors error, xmlSchemaBasicItemPtr item, @@ -2977,7 +2986,7 @@ xmlSchemaPCustomErr(xmlSchemaParserCtxtPtr ctxt, * * Reports an attribute use error during parsing. */ -static void +static void LIBXML_ATTR_FORMAT(6,0) xmlSchemaPAttrUseErr4(xmlSchemaParserCtxtPtr ctxt, xmlParserErrors error, xmlNodePtr node, @@ -3099,7 +3108,7 @@ xmlSchemaPMutualExclAttrErr(xmlSchemaParserCtxtPtr ctxt, * Reports a simple type validation error. * TODO: Should this report the value of an element as well? */ -static void +static void LIBXML_ATTR_FORMAT(8,0) xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, xmlParserErrors error, xmlSchemaBasicItemPtr ownerItem ATTRIBUTE_UNUSED, @@ -3141,11 +3150,13 @@ xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, msg = xmlStrcat(msg, BAD_CAST " '"); if (type->builtInType != 0) { msg = xmlStrcat(msg, BAD_CAST "xs:"); - msg = xmlStrcat(msg, type->name); - } else - msg = xmlStrcat(msg, - xmlSchemaFormatQName(&str, - type->targetNamespace, type->name)); + str = xmlStrdup(type->name); + } else { + const xmlChar *qName = xmlSchemaFormatQName(&str, type->targetNamespace, type->name); + if (!str) + str = xmlStrdup(qName); + } + msg = xmlStrcat(msg, xmlEscapeFormatString(&str)); msg = xmlStrcat(msg, BAD_CAST "'."); FREE_AND_NULL(str); } @@ -3158,7 +3169,9 @@ xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, } if (expected) { msg = xmlStrcat(msg, BAD_CAST " Expected is '"); - msg = xmlStrcat(msg, BAD_CAST expected); + xmlChar *expectedEscaped = xmlCharStrdup(expected); + msg = xmlStrcat(msg, xmlEscapeFormatString(&expectedEscaped)); + FREE_AND_NULL(expectedEscaped); msg = xmlStrcat(msg, BAD_CAST "'.\n"); } else msg = xmlStrcat(msg, BAD_CAST "\n"); @@ -27382,10 +27395,17 @@ xmlSchemaSAXHandleStartElementNs(void *ctx, for (j = 0, i = 0; i < nb_attributes; i++, j += 5) { /* - * Duplicate the value. + * Duplicate the value, changing any & to a literal ampersand. + * + * libxml2 differs from normal SAX here in that it escapes all ampersands + * as & instead of delivering the raw converted string. Changing the + * behavior at this point would break applications that use this API, so + * we are forced to work around it. There is no danger of accidentally + * decoding some entity other than & in this step because without + * unescaped ampersands there can be no other entities in the string. */ - value = xmlStrndup(attributes[j+3], - attributes[j+4] - attributes[j+3]); + value = xmlStringLenDecodeEntities(vctxt->parserCtxt, attributes[j+3], + attributes[j+4] - attributes[j+3], XML_SUBSTITUTE_REF, 0, 0, 0); /* * TODO: Set the node line. */ diff --git a/reactos/sdk/lib/3rdparty/libxml2/xmlschemastypes.c b/reactos/sdk/lib/3rdparty/libxml2/xmlschemastypes.c index ff64f50a648..5f385990446 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xmlschemastypes.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xmlschemastypes.c @@ -62,7 +62,7 @@ struct _xmlSchemaValDate { long year; unsigned int mon :4; /* 1 <= mon <= 12 */ unsigned int day :5; /* 1 <= day <= 31 */ - unsigned int hour :5; /* 0 <= hour <= 23 */ + unsigned int hour :5; /* 0 <= hour <= 24 */ unsigned int min :6; /* 0 <= min <= 59 */ double sec; unsigned int tz_flag :1; /* is tzo explicitely set? */ @@ -1139,9 +1139,13 @@ static const unsigned int daysInMonthLeap[12] = #define VALID_DATE(dt) \ (VALID_YEAR(dt->year) && VALID_MONTH(dt->mon) && VALID_MDAY(dt)) +#define VALID_END_OF_DAY(dt) \ + ((dt)->hour == 24 && (dt)->min == 0 && (dt)->sec == 0) + #define VALID_TIME(dt) \ - (VALID_HOUR(dt->hour) && VALID_MIN(dt->min) && \ - VALID_SEC(dt->sec) && VALID_TZO(dt->tzo)) + (((VALID_HOUR(dt->hour) && VALID_MIN(dt->min) && \ + VALID_SEC(dt->sec)) || VALID_END_OF_DAY(dt)) && \ + VALID_TZO(dt->tzo)) #define VALID_DATETIME(dt) \ (VALID_DATE(dt) && VALID_TIME(dt)) @@ -1355,7 +1359,7 @@ _xmlSchemaParseTime (xmlSchemaValDatePtr dt, const xmlChar **str) { return ret; if (*cur != ':') return 1; - if (!VALID_HOUR(value)) + if (!VALID_HOUR(value) && value != 24 /* Allow end-of-day hour */) return 2; cur++; @@ -1377,7 +1381,7 @@ _xmlSchemaParseTime (xmlSchemaValDatePtr dt, const xmlChar **str) { if (ret != 0) return ret; - if ((!VALID_SEC(dt->sec)) || (!VALID_TZO(dt->tzo))) + if (!VALID_TIME(dt)) return 2; *str = cur; @@ -5303,6 +5307,7 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet, xmlSchemaWhitespaceValueType ws) { int ret; + int stringType; if (facet == NULL) return(-1); @@ -5315,7 +5320,15 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet, */ if (value == NULL) return(-1); - ret = xmlRegexpExec(facet->regexp, value); + /* + * If string-derived type, regexp must be tested on the value space of + * the datatype. + * See https://www.w3.org/TR/xmlschema-2/#rf-pattern + */ + stringType = val && ((val->type >= XML_SCHEMAS_STRING && val->type <= XML_SCHEMAS_NORMSTRING) + || (val->type >= XML_SCHEMAS_TOKEN && val->type <= XML_SCHEMAS_NCNAME)); + ret = xmlRegexpExec(facet->regexp, + (stringType && val->value.str) ? val->value.str : value); if (ret == 1) return(0); if (ret == 0) diff --git a/reactos/sdk/lib/3rdparty/libxml2/xmlstring.c b/reactos/sdk/lib/3rdparty/libxml2/xmlstring.c index a37220d7808..cc85777eadc 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xmlstring.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xmlstring.c @@ -457,6 +457,8 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) { return(xmlStrndup(add, len)); size = xmlStrlen(cur); + if (size < 0) + return(NULL); ret = (xmlChar *) xmlRealloc(cur, (size + len + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlErrMemory(NULL, NULL); @@ -484,14 +486,19 @@ xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) { int size; xmlChar *ret; - if (len < 0) + if (len < 0) { len = xmlStrlen(str2); + if (len < 0) + return(NULL); + } if ((str2 == NULL) || (len == 0)) return(xmlStrdup(str1)); if (str1 == NULL) return(xmlStrndup(str2, len)); size = xmlStrlen(str1); + if (size < 0) + return(NULL); ret = (xmlChar *) xmlMalloc((size + len + 1) * sizeof(xmlChar)); if (ret == NULL) { xmlErrMemory(NULL, NULL); @@ -538,7 +545,7 @@ xmlStrcat(xmlChar *cur, const xmlChar *add) { * Returns the number of characters written to @buf or -1 if an error occurs. */ int XMLCDECL -xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) { +xmlStrPrintf(xmlChar *buf, int len, const char *msg, ...) { va_list args; int ret; @@ -566,7 +573,7 @@ xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) { * Returns the number of characters written to @buf or -1 if an error occurs. */ int -xmlStrVPrintf(xmlChar *buf, int len, const xmlChar *msg, va_list ap) { +xmlStrVPrintf(xmlChar *buf, int len, const char *msg, va_list ap) { int ret; if((buf == NULL) || (msg == NULL)) { @@ -837,8 +844,8 @@ xmlUTF8Strsize(const xmlChar *utf, int len) { break; if ( (ch = *ptr++) & 0x80) while ((ch<<=1) & 0x80 ) { - ptr++; if (*ptr == 0) break; + ptr++; } } return (ptr - utf); @@ -980,5 +987,60 @@ xmlUTF8Strsub(const xmlChar *utf, int start, int len) { return(xmlUTF8Strndup(utf, len)); } +/** + * xmlEscapeFormatString: + * @msg: a pointer to the string in which to escape '%' characters. + * Must be a heap-allocated buffer created by libxml2 that may be + * returned, or that may be freed and replaced. + * + * Replaces the string pointed to by 'msg' with an escaped string. + * Returns the same string with all '%' characters escaped. + */ +xmlChar * +xmlEscapeFormatString(xmlChar **msg) +{ + xmlChar *msgPtr = NULL; + xmlChar *result = NULL; + xmlChar *resultPtr = NULL; + size_t count = 0; + size_t msgLen = 0; + size_t resultLen = 0; + + if (!msg || !*msg) + return(NULL); + + for (msgPtr = *msg; *msgPtr != '\0'; ++msgPtr) { + ++msgLen; + if (*msgPtr == '%') + ++count; + } + + if (count == 0) + return(*msg); + + resultLen = msgLen + count + 1; + result = (xmlChar *) xmlMallocAtomic(resultLen * sizeof(xmlChar)); + if (result == NULL) { + /* Clear *msg to prevent format string vulnerabilities in + out-of-memory situations. */ + xmlFree(*msg); + *msg = NULL; + xmlErrMemory(NULL, NULL); + return(NULL); + } + + for (msgPtr = *msg, resultPtr = result; *msgPtr != '\0'; ++msgPtr, ++resultPtr) { + *resultPtr = *msgPtr; + if (*msgPtr == '%') + *(++resultPtr) = '%'; + } + result[resultLen - 1] = '\0'; + + xmlFree(*msg); + *msg = result; + + return *msg; +} + #define bottom_xmlstring #include "elfgcchack.h" diff --git a/reactos/sdk/lib/3rdparty/libxml2/xmlwriter.c b/reactos/sdk/lib/3rdparty/libxml2/xmlwriter.c index fac20ac0476..69541b894f6 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xmlwriter.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xmlwriter.c @@ -113,7 +113,7 @@ static int xmlTextWriterWriteDocCallback(void *context, const xmlChar * str, int len); static int xmlTextWriterCloseDocCallback(void *context); -static xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr); +static xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr) LIBXML_ATTR_FORMAT(1,0); static int xmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len, const unsigned char *data); static void xmlTextWriterStartDocumentCallback(void *ctx); @@ -153,7 +153,7 @@ xmlWriterErrMsg(xmlTextWriterPtr ctxt, xmlParserErrors error, * * Handle a writer error */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlWriterErrMsgInt(xmlTextWriterPtr ctxt, xmlParserErrors error, const char *msg, int val) { diff --git a/reactos/sdk/lib/3rdparty/libxml2/xpath.c b/reactos/sdk/lib/3rdparty/libxml2/xpath.c index 935fcff026a..113bce64dd9 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xpath.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xpath.c @@ -639,7 +639,7 @@ xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra) xmlChar buf[200]; xmlStrPrintf(buf, 200, - BAD_CAST "Memory allocation failed : %s\n", + "Memory allocation failed : %s\n", extra); ctxt->lastError.message = (char *) xmlStrdup(buf); } else { @@ -945,7 +945,7 @@ struct _xmlXPathCompExpr { xmlXPathStepOp *steps; /* ops for computation of this expression */ int last; /* index of last step in expression */ xmlChar *expr; /* the expression being computed */ - xmlDictPtr dict; /* the dictionnary to use if any */ + xmlDictPtr dict; /* the dictionary to use if any */ #ifdef DEBUG_EVAL_COUNTS int nb; xmlChar *string; @@ -3706,7 +3706,7 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) { /* @@ with_ns to check whether namespace nodes should be looked at @@ */ /* - * prevent duplcates + * prevent duplicates */ for (i = 0;i < cur->nodeNr;i++) if (cur->nodeTab[i] == val) return(0); @@ -8390,7 +8390,7 @@ xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if (ctxt->context->node->type != XML_ELEMENT_NODE) return(NULL); - if (ctxt->context->tmpNsList == NULL && cur != (xmlNodePtr) xmlXPathXMLNamespace) { + if (cur == NULL) { if (ctxt->context->tmpNsList != NULL) xmlFree(ctxt->context->tmpNsList); ctxt->context->tmpNsList = @@ -9996,7 +9996,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) { (c == '[') || (c == ']') || (c == '@') || /* accelerators */ (c == '*') || /* accelerators */ (!IS_LETTER(c) && (c != '_') && - ((qualified) && (c != ':')))) { + ((!qualified) || (c != ':')))) { return(NULL); } @@ -12379,11 +12379,6 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, STRANGE goto error; case NODE_TEST_TYPE: - /* - * TODO: Don't we need to use - * xmlXPathNodeSetAddNs() for namespace nodes here? - * Surprisingly, some c14n tests fail, if we do this. - */ if (type == NODE_TYPE_NODE) { switch (cur->type) { case XML_DOCUMENT_NODE: @@ -12397,9 +12392,17 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, case XML_COMMENT_NODE: case XML_CDATA_SECTION_NODE: case XML_TEXT_NODE: - case XML_NAMESPACE_DECL: XP_TEST_HIT break; + case XML_NAMESPACE_DECL: { + if (axis == AXIS_NAMESPACE) { + XP_TEST_HIT_NS + } else { + hasNsNodes = 1; + XP_TEST_HIT + } + break; + } default: break; } @@ -12691,6 +12694,14 @@ error: * Reset the context node. */ xpctxt->node = oldContextNode; + /* + * When traversing the namespace axis in "toBool" mode, it's + * possible that tmpNsList wasn't freed. + */ + if (xpctxt->tmpNsList != NULL) { + xmlFree(xpctxt->tmpNsList); + xpctxt->tmpNsList = NULL; + } #ifdef DEBUG_STEP xmlGenericError(xmlGenericErrorContext, @@ -14784,6 +14795,10 @@ xmlXPathOptimizeExpression(xmlXPathCompExprPtr comp, xmlXPathStepOpPtr op) } } + /* OP_VALUE has invalid ch1. */ + if (op->op == XPATH_OP_VALUE) + return; + /* Recurse */ if (op->ch1 != -1) xmlXPathOptimizeExpression(comp, &comp->steps[op->ch1]); diff --git a/reactos/sdk/lib/3rdparty/libxml2/xpointer.c b/reactos/sdk/lib/3rdparty/libxml2/xpointer.c index 4b4ac2ee5c9..676c5105837 100644 --- a/reactos/sdk/lib/3rdparty/libxml2/xpointer.c +++ b/reactos/sdk/lib/3rdparty/libxml2/xpointer.c @@ -85,7 +85,7 @@ xmlXPtrErrMemory(const char *extra) * * Handle a redefinition of attribute error */ -static void +static void LIBXML_ATTR_FORMAT(3,0) xmlXPtrErr(xmlXPathParserContextPtr ctxt, int error, const char * msg, const xmlChar *extra) {