diff options
author | Aron Xu <aron@debian.org> | 2012-04-18 15:58:48 +0800 |
---|---|---|
committer | Aron Xu <aron@debian.org> | 2012-04-23 00:25:41 +0800 |
commit | 4281fb7adc1b49f8038085cd294327a4338b7082 (patch) | |
tree | 23d0bb5616d39b6e757f5ecaabf58cfb61b156fd /debian/patches | |
parent | 6205aa529c62396b509525bc4283e765ae0ebee8 (diff) | |
download | libxml2-4281fb7adc1b49f8038085cd294327a4338b7082.tar.gz |
Port existing patch to quilt.
Diffstat (limited to 'debian/patches')
-rw-r--r-- | debian/patches/01_build-system.patch | 55 | ||||
-rw-r--r-- | debian/patches/01_historical_changes.patch | 899 | ||||
-rw-r--r-- | debian/patches/series | 2 |
3 files changed, 900 insertions, 56 deletions
diff --git a/debian/patches/01_build-system.patch b/debian/patches/01_build-system.patch deleted file mode 100644 index 16a9c9f..0000000 --- a/debian/patches/01_build-system.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- a/Makefile.am -+++ b/Makefile.am -@@ -8,10 +8,10 @@ - - INCLUDES = -I$(top_builddir)/include -I@srcdir@/include @THREAD_CFLAGS@ @Z_CFLAGS@ - --noinst_PROGRAMS=testSchemas testRelax testSAX testHTML testXPath testURI \ -- testThreads testC14N testAutomata testRegexp \ -- testReader testapi testModule runtest runsuite testchar \ -- testdict runxmlconf testrecurse -+#noinst_PROGRAMS=testSchemas testRelax testSAX testHTML testXPath testURI \ -+# testThreads testC14N testAutomata testRegexp \ -+# testReader testapi testModule runtest runsuite testchar \ -+# testdict runxmlconf testrecurse - - bin_PROGRAMS = xmllint xmlcatalog - -@@ -157,7 +157,7 @@ - testModule_DEPENDENCIES = $(DEPS) - testModule_LDADD= $(LDADDS) - --noinst_LTLIBRARIES = testdso.la -+#noinst_LTLIBRARIES = testdso.la - testdso_la_SOURCES = testdso.c - testdso_la_LDFLAGS = -module -no-undefined -avoid-version -rpath $(libdir) - ---- a/configure.in -+++ b/configure.in -@@ -70,6 +70,8 @@ - AC_LIBTOOL_WIN32_DLL - AM_PROG_LIBTOOL - -+AM_MAINTAINER_MODE -+ - dnl - dnl if the system support linker version scripts for symbol versioning - dnl then add it -@@ -84,7 +86,7 @@ - esac - fi - AC_SUBST(VERSION_SCRIPT_FLAGS) --AM_CONDITIONAL([USE_VERSION_SCRIPT], [test -z "$VERSION_SCRIPT_FLAGS"]) -+AM_CONDITIONAL([USE_VERSION_SCRIPT], [test -n "$VERSION_SCRIPT_FLAGS"]) - - dnl - dnl We process the AC_ARG_WITH first so that later we can modify -@@ -1319,7 +1321,7 @@ - *) M_LIBS="-lm" - ;; - esac --XML_LIBS="-lxml2 $Z_LIBS $THREAD_LIBS $ICONV_LIBS $M_LIBS $LIBS" -+XML_LIBS="-lxml2" - XML_LIBTOOLLIBS="libxml2.la" - AC_SUBST(WITH_ICONV) - diff --git a/debian/patches/01_historical_changes.patch b/debian/patches/01_historical_changes.patch new file mode 100644 index 0000000..81004ba --- /dev/null +++ b/debian/patches/01_historical_changes.patch @@ -0,0 +1,899 @@ +--- a/Makefile.am ++++ b/Makefile.am +@@ -8,10 +8,10 @@ + + INCLUDES = -I$(top_builddir)/include -I@srcdir@/include @THREAD_CFLAGS@ @Z_CFLAGS@ + +-noinst_PROGRAMS=testSchemas testRelax testSAX testHTML testXPath testURI \ +- testThreads testC14N testAutomata testRegexp \ +- testReader testapi testModule runtest runsuite testchar \ +- testdict runxmlconf testrecurse ++#noinst_PROGRAMS=testSchemas testRelax testSAX testHTML testXPath testURI \ ++# testThreads testC14N testAutomata testRegexp \ ++# testReader testapi testModule runtest runsuite testchar \ ++# testdict runxmlconf testrecurse + + bin_PROGRAMS = xmllint xmlcatalog + +@@ -157,7 +157,7 @@ + testModule_DEPENDENCIES = $(DEPS) + testModule_LDADD= $(LDADDS) + +-noinst_LTLIBRARIES = testdso.la ++#noinst_LTLIBRARIES = testdso.la + testdso_la_SOURCES = testdso.c + testdso_la_LDFLAGS = -module -no-undefined -avoid-version -rpath $(libdir) + +--- a/configure.in ++++ b/configure.in +@@ -1,6 +1,6 @@ + dnl Process this file with autoconf to produce a configure script. + AC_PREREQ(2.59) +-AC_INIT(entities.c) ++AC_INIT(entities.c, 2.7.8) + AM_CONFIG_HEADER(config.h) + AC_CONFIG_MACRO_DIR([m4]) + AC_CANONICAL_HOST +@@ -48,6 +48,7 @@ + + VERSION=${LIBXML_VERSION} + ++AM_INIT_AUTOMAKE([1.10 no-define foreign]) + AM_INIT_AUTOMAKE(libxml2, $VERSION) + + dnl Checks for programs. +@@ -70,6 +71,8 @@ + AC_LIBTOOL_WIN32_DLL + AM_PROG_LIBTOOL + ++AM_MAINTAINER_MODE ++ + dnl + dnl if the system support linker version scripts for symbol versioning + dnl then add it +@@ -84,7 +87,7 @@ + esac + fi + AC_SUBST(VERSION_SCRIPT_FLAGS) +-AM_CONDITIONAL([USE_VERSION_SCRIPT], [test -z "$VERSION_SCRIPT_FLAGS"]) ++AM_CONDITIONAL([USE_VERSION_SCRIPT], [test -n "$VERSION_SCRIPT_FLAGS"]) + + dnl + dnl We process the AC_ARG_WITH first so that later we can modify +@@ -1319,7 +1322,7 @@ + *) M_LIBS="-lm" + ;; + esac +-XML_LIBS="-lxml2 $Z_LIBS $THREAD_LIBS $ICONV_LIBS $M_LIBS $LIBS" ++XML_LIBS="-lxml2" + XML_LIBTOOLLIBS="libxml2.la" + AC_SUBST(WITH_ICONV) + +--- a/dict.c ++++ b/dict.c +@@ -19,6 +19,28 @@ + #define IN_LIBXML + #include "libxml.h" + ++#ifdef HAVE_STDLIB_H ++#include <stdlib.h> ++#endif ++#ifdef HAVE_TIME_H ++#include <time.h> ++#endif ++ ++/* ++ * Following http://www.ocert.org/advisories/ocert-2011-003.html ++ * it seems that having hash randomization might be a good idea ++ * when using XML with untrusted data ++ * Note1: that it works correctly only if compiled with WITH_BIG_KEY ++ * which is the default. ++ * Note2: the fast function used for a small dict won't protect very ++ * well but since the attack is based on growing a very big hash ++ * list we will use the BigKey algo as soon as the hash size grows ++ * over MIN_DICT_SIZE so this actually works ++ */ ++#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME) ++#define DICT_RANDOMIZATION ++#endif ++ + #include <string.h> + #ifdef HAVE_STDINT_H + #include <stdint.h> +@@ -44,23 +66,23 @@ + #define WITH_BIG_KEY + + #ifdef WITH_BIG_KEY +-#define xmlDictComputeKey(dict, name, len) \ +- (((dict)->size == MIN_DICT_SIZE) ? \ +- xmlDictComputeFastKey(name, len) : \ +- xmlDictComputeBigKey(name, len)) +- +-#define xmlDictComputeQKey(dict, prefix, plen, name, len) \ +- (((prefix) == NULL) ? \ +- (xmlDictComputeKey(dict, name, len)) : \ +- (((dict)->size == MIN_DICT_SIZE) ? \ +- xmlDictComputeFastQKey(prefix, plen, name, len) : \ +- xmlDictComputeBigQKey(prefix, plen, name, len))) ++#define xmlDictComputeKey(dict, name, len) \ ++ (((dict)->size == MIN_DICT_SIZE) ? \ ++ xmlDictComputeFastKey(name, len, (dict)->seed) : \ ++ xmlDictComputeBigKey(name, len, (dict)->seed)) ++ ++#define xmlDictComputeQKey(dict, prefix, plen, name, len) \ ++ (((prefix) == NULL) ? \ ++ (xmlDictComputeKey(dict, name, len)) : \ ++ (((dict)->size == MIN_DICT_SIZE) ? \ ++ xmlDictComputeFastQKey(prefix, plen, name, len, (dict)->seed) : \ ++ xmlDictComputeBigQKey(prefix, plen, name, len, (dict)->seed))) + + #else /* !WITH_BIG_KEY */ +-#define xmlDictComputeKey(dict, name, len) \ +- xmlDictComputeFastKey(name, len) +-#define xmlDictComputeQKey(dict, prefix, plen, name, len) \ +- xmlDictComputeFastQKey(prefix, plen, name, len) ++#define xmlDictComputeKey(dict, name, len) \ ++ xmlDictComputeFastKey(name, len, (dict)->seed) ++#define xmlDictComputeQKey(dict, prefix, plen, name, len) \ ++ xmlDictComputeFastQKey(prefix, plen, name, len, (dict)->seed) + #endif /* WITH_BIG_KEY */ + + /* +@@ -98,6 +120,8 @@ + xmlDictStringsPtr strings; + + struct _xmlDict *subdict; ++ /* used for randomization */ ++ int seed; + }; + + /* +@@ -125,6 +149,10 @@ + if ((xmlDictMutex = xmlNewRMutex()) == NULL) + return(0); + ++#ifdef DICT_RANDOMIZATION ++ srand(time(NULL)); ++#endif ++ + xmlDictInitialized = 1; + return(1); + } +@@ -277,13 +305,13 @@ + */ + + static uint32_t +-xmlDictComputeBigKey(const xmlChar* data, int namelen) { ++xmlDictComputeBigKey(const xmlChar* data, int namelen, int seed) { + uint32_t hash; + int i; + + if (namelen <= 0 || data == NULL) return(0); + +- hash = 0; ++ hash = seed; + + for (i = 0;i < namelen; i++) { + hash += data[i]; +@@ -310,12 +338,12 @@ + */ + static unsigned long + xmlDictComputeBigQKey(const xmlChar *prefix, int plen, +- const xmlChar *name, int len) ++ const xmlChar *name, int len, int seed) + { + uint32_t hash; + int i; + +- hash = 0; ++ hash = seed; + + for (i = 0;i < plen; i++) { + hash += prefix[i]; +@@ -346,8 +374,8 @@ + * for low hash table fill. + */ + static unsigned long +-xmlDictComputeFastKey(const xmlChar *name, int namelen) { +- unsigned long value = 0L; ++xmlDictComputeFastKey(const xmlChar *name, int namelen, int seed) { ++ unsigned long value = seed; + + if (name == NULL) return(0); + value = *name; +@@ -381,9 +409,9 @@ + */ + static unsigned long + xmlDictComputeFastQKey(const xmlChar *prefix, int plen, +- const xmlChar *name, int len) ++ const xmlChar *name, int len, int seed) + { +- unsigned long value = 0L; ++ unsigned long value = seed; + + if (plen == 0) + value += 30 * (unsigned long) ':'; +@@ -460,6 +488,11 @@ + dict->subdict = NULL; + if (dict->dict) { + memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry)); ++#ifdef DICT_RANDOMIZATION ++ dict->seed = rand(); ++#else ++ dict->seed = 0; ++#endif + return(dict); + } + xmlFree(dict); +--- a/encoding.c ++++ b/encoding.c +@@ -1928,7 +1928,7 @@ + if (in == NULL) return(-1); + + /* calculate space available */ +- written = out->size - out->use; ++ written = out->size - out->use - 1; /* count '\0' */ + toconv = in->use; + /* + * echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38 +@@ -2059,7 +2059,7 @@ + toconv = in->use; + if (toconv == 0) + return (0); +- written = out->size - out->use; ++ written = out->size - out->use - 1; /* count '\0' */ + if (toconv * 2 >= written) { + xmlBufferGrow(out, out->size + toconv * 2); + written = out->size - out->use - 1; +--- a/error.c ++++ b/error.c +@@ -452,6 +452,8 @@ + xmlErrorPtr to = &xmlLastError; + xmlNodePtr baseptr = NULL; + ++ if (code == XML_ERR_OK) ++ return; + if ((xmlGetWarningsDefaultValue == 0) && (level == XML_ERR_WARNING)) + return; + if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) || +@@ -459,8 +461,11 @@ + (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) { + ctxt = (xmlParserCtxtPtr) ctx; + if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) && +- (ctxt->sax->initialized == XML_SAX2_MAGIC)) ++ (ctxt->sax->initialized == XML_SAX2_MAGIC) && ++ (ctxt->sax->serror != NULL)) { + schannel = ctxt->sax->serror; ++ data = ctxt->userData; ++ } + } + /* + * Check if structured error handler set +@@ -473,16 +478,6 @@ + if (schannel != NULL) + data = xmlStructuredErrorContext; + } +- if ((domain == XML_FROM_VALID) && +- ((channel == xmlParserValidityError) || +- (channel == xmlParserValidityWarning))) { +- ctxt = (xmlParserCtxtPtr) ctx; +- if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) && +- (ctxt->sax->initialized == XML_SAX2_MAGIC)) +- schannel = ctxt->sax->serror; +- } +- if (code == XML_ERR_OK) +- return; + /* + * Formatting the message + */ +@@ -589,6 +584,10 @@ + if (to != &xmlLastError) + xmlCopyError(to,&xmlLastError); + ++ if (schannel != NULL) { ++ schannel(data, to); ++ return; ++ } + /* + * Find the callback channel if channel param is NULL + */ +@@ -600,19 +599,9 @@ + channel = ctxt->sax->error; + data = ctxt->userData; + } else if (channel == NULL) { +- if ((schannel == NULL) && (xmlStructuredError != NULL)) { +- schannel = xmlStructuredError; +- data = xmlStructuredErrorContext; +- } else { +- channel = xmlGenericError; +- if (!data) { +- data = xmlGenericErrorContext; +- } +- } +- } +- if (schannel != NULL) { +- schannel(data, to); +- return; ++ channel = xmlGenericError; ++ if (!data) ++ data = xmlGenericErrorContext; + } + if (channel == NULL) + return; +--- a/hash.c ++++ b/hash.c +@@ -21,6 +21,22 @@ + #include "libxml.h" + + #include <string.h> ++#ifdef HAVE_STDLIB_H ++#include <stdlib.h> ++#endif ++#ifdef HAVE_TIME_H ++#include <time.h> ++#endif ++ ++/* ++ * Following http://www.ocert.org/advisories/ocert-2011-003.html ++ * it seems that having hash randomization might be a good idea ++ * when using XML with untrusted data ++ */ ++#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME) ++#define HASH_RANDOMIZATION ++#endif ++ + #include <libxml/parser.h> + #include <libxml/hash.h> + #include <libxml/xmlmemory.h> +@@ -31,6 +47,10 @@ + + /* #define DEBUG_GROW */ + ++#ifdef HASH_RANDOMIZATION ++static int hash_initialized = 0; ++#endif ++ + /* + * A single entry in the hash table + */ +@@ -53,6 +73,9 @@ + int size; + int nbElems; + xmlDictPtr dict; ++#ifdef HASH_RANDOMIZATION ++ int random_seed; ++#endif + }; + + /* +@@ -65,6 +88,9 @@ + unsigned long value = 0L; + char ch; + ++#ifdef HASH_RANDOMIZATION ++ value = table->random_seed; ++#endif + if (name != NULL) { + value += 30 * (*name); + while ((ch = *name++) != 0) { +@@ -156,6 +182,13 @@ + table->table = xmlMalloc(size * sizeof(xmlHashEntry)); + if (table->table) { + memset(table->table, 0, size * sizeof(xmlHashEntry)); ++#ifdef HASH_RANDOMIZATION ++ if (!hash_initialized) { ++ srand(time(NULL)); ++ hash_initialized = 1; ++ } ++ table->random_seed = rand(); ++#endif + return(table); + } + xmlFree(table); +--- a/include/libxml/xpath.h ++++ b/include/libxml/xpath.h +@@ -68,7 +68,8 @@ + XPATH_UNDEF_PREFIX_ERROR, + XPATH_ENCODING_ERROR, + XPATH_INVALID_CHAR_ERROR, +- XPATH_INVALID_CTXT ++ XPATH_INVALID_CTXT, ++ XPATH_STACK_ERROR + } xmlXPathError; + + /* +@@ -380,6 +381,9 @@ + xmlXPathCompExprPtr comp; /* the precompiled expression */ + int xptr; /* it this an XPointer expression */ + xmlNodePtr ancestor; /* used for walking preceding axis */ ++ ++ int valueFrame; /* used to limit Pop on the stack */ ++ + }; + + /************************************************************************ +--- a/libxml-2.0-uninstalled.pc.in ++++ b/libxml-2.0-uninstalled.pc.in +@@ -8,5 +8,6 @@ + Version: @VERSION@ + Description: libXML library version2. + Requires: +-Libs: -L${libdir} -lxml2 @THREAD_LIBS@ @Z_LIBS@ @ICONV_LIBS@ @M_LIBS@ @LIBS@ ++Libs: -L${libdir} -lxml2 ++Libs.private: @BASE_THREAD_LIBS@ @THREAD_LIBS@ @Z_LIBS@ @ICONV_LIBS@ @M_LIBS@ @LIBS@ + Cflags: -I${includedir} @XML_INCLUDEDIR@ @XML_CFLAGS@ +--- a/libxml.h ++++ b/libxml.h +@@ -13,6 +13,9 @@ + #ifndef _LARGEFILE_SOURCE + #define _LARGEFILE_SOURCE + #endif ++#ifndef _LARGEFILE64_SOURCE ++#define _LARGEFILE64_SOURCE ++#endif + #ifndef _FILE_OFFSET_BITS + #define _FILE_OFFSET_BITS 64 + #endif +--- a/parser.c ++++ b/parser.c +@@ -2709,7 +2709,7 @@ + + buffer[nbchars++] = '&'; + if (nbchars > buffer_size - i - XML_PARSER_BUFFER_SIZE) { +- growBuffer(buffer, XML_PARSER_BUFFER_SIZE); ++ growBuffer(buffer, i + XML_PARSER_BUFFER_SIZE); + } + for (;i > 0;i--) + buffer[nbchars++] = *cur++; +@@ -4949,7 +4949,8 @@ + (ctxt->sax->processingInstruction != NULL)) + ctxt->sax->processingInstruction(ctxt->userData, + target, NULL); +- ctxt->instate = state; ++ if (ctxt->instate != XML_PARSER_EOF) ++ ctxt->instate = state; + return; + } + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); +@@ -5029,7 +5030,8 @@ + } else { + xmlFatalErr(ctxt, XML_ERR_PI_NOT_STARTED, NULL); + } +- ctxt->instate = state; ++ if (ctxt->instate != XML_PARSER_EOF) ++ ctxt->instate = state; + } + } + +@@ -9588,6 +9590,8 @@ + else + name = xmlParseStartTag(ctxt); + #endif /* LIBXML_SAX1_ENABLED */ ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if (name == NULL) { + spacePop(ctxt); + return; +@@ -10967,6 +10971,8 @@ + else + name = xmlParseStartTag(ctxt); + #endif /* LIBXML_SAX1_ENABLED */ ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + if (name == NULL) { + spacePop(ctxt); + ctxt->instate = XML_PARSER_EOF; +@@ -11153,7 +11159,9 @@ + else + xmlParseEndTag1(ctxt, 0); + #endif /* LIBXML_SAX1_ENABLED */ +- if (ctxt->nameNr == 0) { ++ if (ctxt->instate == XML_PARSER_EOF) { ++ /* Nothing */ ++ } else if (ctxt->nameNr == 0) { + ctxt->instate = XML_PARSER_EPILOG; + } else { + ctxt->instate = XML_PARSER_CONTENT; +--- a/xml2-config.1 ++++ b/xml2-config.1 +@@ -9,7 +9,6 @@ + linker flags that should be used to compile and link programs that use + \fIGNOME-XML\fP. + .SH OPTIONS +-.l + \fIxml-config\fP accepts the following options: + .TP 8 + .B \-\-version +@@ -17,6 +16,8 @@ + .TP 8 + .B \-\-libs + Print the linker flags that are necessary to link a \fIGNOME-XML\fP program. ++Add the \fB\-\-static\fP option to print the linker flags that are necessary to ++\fBstatically\fP link a \fIGNOME-XML\fP program. + .TP 8 + .B \-\-cflags + Print the compiler flags that are necessary to compile a \fIGNOME-XML\fP program. +--- a/xml2-config.in ++++ b/xml2-config.in +@@ -15,6 +15,7 @@ + --prefix=DIR change libxml prefix [default $prefix] + --exec-prefix=DIR change libxml exec prefix [default $exec_prefix] + --libs print library linking information ++ add --static to print static library linking information + --cflags print pre-processor and compiler flags + --modules module support enabled + --help display this help and exit +@@ -86,13 +87,19 @@ + then + if [ "@XML_LIBDIR@" = "-L/usr/lib" -o "@XML_LIBDIR@" = "-L/usr/lib64" ] + then +- echo @XML_LIBS@ ++ LIBS="@XML_LIBS@ " + else +- echo @XML_LIBDIR@ @XML_LIBS@ ++ LIBS="@XML_LIBDIR@ @XML_LIBS@" + fi + else +- echo @XML_LIBDIR@ @XML_LIBS@ @WIN32_EXTRA_LIBADD@ ++ LIBS="@XML_LIBDIR@ @XML_LIBS@ @WIN32_EXTRA_LIBADD@" + fi ++ if [ "$2" = "--static" ] ++ then ++ shift ++ LIBS="${LIBS} @Z_LIBS@ @BASE_THREAD_LIBS@ @THREAD_LIBS@ @ICONV_LIBS@ @M_LIBS@ @LIBS@" ++ fi ++ echo ${LIBS} + ;; + + *) +--- a/xmllint.c ++++ b/xmllint.c +@@ -2976,7 +2976,7 @@ + printf("\t--huge : remove any internal arbitrary parser limits\n"); + printf("\t--noent : substitute entity references by their value\n"); + printf("\t--noout : don't output the result tree\n"); +- printf("\t--path 'paths': provide a set of paths for resources\n"); ++ printf("\t--path 'paths' : provide a set of paths for resources\n"); + printf("\t--load-trace : print trace of all external entites loaded\n"); + printf("\t--nonet : refuse to fetch DTDs or entities over network\n"); + printf("\t--nocompact : do not generate compact text nodes\n"); +@@ -3032,7 +3032,7 @@ + printf("\t--catalogs : use SGML catalogs from $SGML_CATALOG_FILES\n"); + printf("\t otherwise XML Catalogs starting from \n"); + printf("\t %s are activated by default\n", XML_XML_DEFAULT_CATALOG); +- printf("\t--nocatalogs: deactivate all catalogs\n"); ++ printf("\t--nocatalogs : deactivate all catalogs\n"); + #endif + printf("\t--auto : generate a small doc on the fly\n"); + #ifdef LIBXML_XINCLUDE_ENABLED +--- a/xpath.c ++++ b/xpath.c +@@ -252,6 +252,7 @@ + "Encoding error\n", + "Char out of XML range\n", + "Invalid or incomplete context\n", ++ "Stack usage errror\n", + "?? Unknown error ??\n" /* Must be last in the list! */ + }; + #define MAXERRNO ((int)(sizeof(xmlXPathErrorMessages) / \ +@@ -2398,6 +2399,42 @@ + ************************************************************************/ + + /** ++ * xmlXPathSetFrame: ++ * @ctxt: an XPath parser context ++ * ++ * Set the callee evaluation frame ++ * ++ * Returns the previous frame value to be restored once done ++ */ ++static int ++xmlXPathSetFrame(xmlXPathParserContextPtr ctxt) { ++ int ret; ++ ++ if (ctxt == NULL) ++ return(0); ++ ret = ctxt->valueFrame; ++ ctxt->valueFrame = ctxt->valueNr; ++ return(ret); ++} ++ ++/** ++ * xmlXPathPopFrame: ++ * @ctxt: an XPath parser context ++ * @frame: the previous frame value ++ * ++ * Remove the callee evaluation frame ++ */ ++static void ++xmlXPathPopFrame(xmlXPathParserContextPtr ctxt, int frame) { ++ if (ctxt == NULL) ++ return; ++ if (ctxt->valueNr < ctxt->valueFrame) { ++ xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR); ++ } ++ ctxt->valueFrame = frame; ++} ++ ++/** + * valuePop: + * @ctxt: an XPath evaluation context + * +@@ -2412,6 +2449,12 @@ + + if ((ctxt == NULL) || (ctxt->valueNr <= 0)) + return (NULL); ++ ++ if (ctxt->valueNr <= ctxt->valueFrame) { ++ xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR); ++ return (NULL); ++ } ++ + ctxt->valueNr--; + if (ctxt->valueNr > 0) + ctxt->value = ctxt->valueTab[ctxt->valueNr - 1]; +@@ -3523,12 +3566,13 @@ + xmlNodePtr *temp; + + cur->nodeMax *= 2; +- temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * ++ temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * 2 * + sizeof(xmlNodePtr)); + if (temp == NULL) { + xmlXPathErrMemory(NULL, "growing nodeset\n"); + return; + } ++ cur->nodeMax *= 2; + cur->nodeTab = temp; + } + cur->nodeTab[cur->nodeNr++] = xmlXPathNodeSetDupNs(node, ns); +@@ -3627,14 +3671,14 @@ + } else if (cur->nodeNr == cur->nodeMax) { + xmlNodePtr *temp; + +- cur->nodeMax *= 2; +- temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * ++ temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * 2 * + sizeof(xmlNodePtr)); + if (temp == NULL) { + xmlXPathErrMemory(NULL, "growing nodeset\n"); + return; + } + cur->nodeTab = temp; ++ cur->nodeMax *= 2; + } + if (val->type == XML_NAMESPACE_DECL) { + xmlNsPtr ns = (xmlNsPtr) val; +@@ -3738,14 +3782,14 @@ + } else if (val1->nodeNr == val1->nodeMax) { + xmlNodePtr *temp; + +- val1->nodeMax *= 2; +- temp = (xmlNodePtr *) xmlRealloc(val1->nodeTab, val1->nodeMax * ++ temp = (xmlNodePtr *) xmlRealloc(val1->nodeTab, val1->nodeMax * 2 * + sizeof(xmlNodePtr)); + if (temp == NULL) { + xmlXPathErrMemory(NULL, "merging nodeset\n"); + return(NULL); + } + val1->nodeTab = temp; ++ val1->nodeMax *= 2; + } + if (n2->type == XML_NAMESPACE_DECL) { + xmlNsPtr ns = (xmlNsPtr) n2; +@@ -3907,14 +3951,14 @@ + } else if (set1->nodeNr >= set1->nodeMax) { + xmlNodePtr *temp; + +- set1->nodeMax *= 2; + temp = (xmlNodePtr *) xmlRealloc( +- set1->nodeTab, set1->nodeMax * sizeof(xmlNodePtr)); ++ set1->nodeTab, set1->nodeMax * 2 * sizeof(xmlNodePtr)); + if (temp == NULL) { + xmlXPathErrMemory(NULL, "merging nodeset\n"); + return(NULL); + } + set1->nodeTab = temp; ++ set1->nodeMax *= 2; + } + if (n2->type == XML_NAMESPACE_DECL) { + xmlNsPtr ns = (xmlNsPtr) n2; +@@ -3991,14 +4035,14 @@ + } else if (set1->nodeNr >= set1->nodeMax) { + xmlNodePtr *temp; + +- set1->nodeMax *= 2; + temp = (xmlNodePtr *) xmlRealloc( +- set1->nodeTab, set1->nodeMax * sizeof(xmlNodePtr)); ++ set1->nodeTab, set1->nodeMax * 2 * sizeof(xmlNodePtr)); + if (temp == NULL) { + xmlXPathErrMemory(NULL, "merging nodeset\n"); + return(NULL); + } + set1->nodeTab = temp; ++ set1->nodeMax *= 2; + } + set1->nodeTab[set1->nodeNr++] = n2; + } +@@ -6154,6 +6198,7 @@ + ret->valueNr = 0; + ret->valueMax = 10; + ret->value = NULL; ++ ret->valueFrame = 0; + + ret->context = ctxt; + ret->comp = comp; +@@ -11712,6 +11757,7 @@ + xmlXPathObjectPtr contextObj = NULL, exprRes = NULL; + xmlNodePtr oldContextNode, contextNode = NULL; + xmlXPathContextPtr xpctxt = ctxt->context; ++ int frame; + + #ifdef LIBXML_XPTR_ENABLED + /* +@@ -11731,6 +11777,7 @@ + */ + exprOp = &ctxt->comp->steps[op->ch2]; + for (i = 0; i < set->nodeNr; i++) { ++ xmlXPathObjectPtr tmp; + if (set->nodeTab[i] == NULL) + continue; + +@@ -11758,18 +11805,25 @@ + xmlXPathNodeSetAddUnique(contextObj->nodesetval, + contextNode); + ++ frame = xmlXPathSetFrame(ctxt); + valuePush(ctxt, contextObj); + res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1); ++ tmp = valuePop(ctxt); ++ xmlXPathPopFrame(ctxt, frame); + + if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) { +- xmlXPathObjectPtr tmp; +- /* pop the result */ +- tmp = valuePop(ctxt); +- xmlXPathReleaseObject(xpctxt, tmp); +- /* then pop off contextObj, which will be freed later */ +- valuePop(ctxt); ++ while (tmp != contextObj) { ++ /* ++ * Free up the result ++ * then pop off contextObj, which will be freed later ++ */ ++ xmlXPathReleaseObject(xpctxt, tmp); ++ tmp = valuePop(ctxt); ++ } + goto evaluation_error; + } ++ /* push the result back onto the stack */ ++ valuePush(ctxt, tmp); + + if (res) + pos++; +@@ -13357,6 +13411,7 @@ + xmlGenericError(xmlGenericErrorContext, + "xmlXPathCompOpEval: variable %s bound to undefined prefix %s\n", + (char *) op->value4, (char *)op->value5); ++ ctxt->error = XPATH_UNDEF_PREFIX_ERROR; + return (total); + } + val = xmlXPathVariableLookupNS(ctxt->context, +@@ -13373,7 +13428,9 @@ + xmlXPathFunction func; + const xmlChar *oldFunc, *oldFuncURI; + int i; ++ int frame; + ++ frame = xmlXPathSetFrame(ctxt); + if (op->ch1 != -1) + total += + xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); +@@ -13381,15 +13438,18 @@ + xmlGenericError(xmlGenericErrorContext, + "xmlXPathCompOpEval: parameter error\n"); + ctxt->error = XPATH_INVALID_OPERAND; ++ xmlXPathPopFrame(ctxt, frame); + return (total); + } +- for (i = 0; i < op->value; i++) ++ for (i = 0; i < op->value; i++) { + if (ctxt->valueTab[(ctxt->valueNr - 1) - i] == NULL) { + xmlGenericError(xmlGenericErrorContext, + "xmlXPathCompOpEval: parameter error\n"); + ctxt->error = XPATH_INVALID_OPERAND; ++ xmlXPathPopFrame(ctxt, frame); + return (total); + } ++ } + if (op->cache != NULL) + XML_CAST_FPTR(func) = op->cache; + else { +@@ -13405,6 +13465,8 @@ + xmlGenericError(xmlGenericErrorContext, + "xmlXPathCompOpEval: function %s bound to undefined prefix %s\n", + (char *)op->value4, (char *)op->value5); ++ ctxt->error = XPATH_UNDEF_PREFIX_ERROR; ++ xmlXPathPopFrame(ctxt, frame); + return (total); + } + func = xmlXPathFunctionLookupNS(ctxt->context, +@@ -13426,6 +13488,7 @@ + func(ctxt, op->value); + ctxt->context->function = oldFunc; + ctxt->context->functionURI = oldFuncURI; ++ xmlXPathPopFrame(ctxt, frame); + return (total); + } + case XPATH_OP_ARG: +@@ -14329,6 +14392,7 @@ + ctxt->valueNr = 0; + ctxt->valueMax = 10; + ctxt->value = NULL; ++ ctxt->valueFrame = 0; + } + #ifdef XPATH_STREAMING + if (ctxt->comp->stream) { +--- a/xpointer.c ++++ b/xpointer.c +@@ -1269,6 +1269,7 @@ + ctxt->valueNr = 0; + ctxt->valueMax = 10; + ctxt->value = NULL; ++ ctxt->valueFrame = 0; + } + SKIP_BLANKS; + if (CUR == '/') { +--- a/doc/devhelp/Makefile.am ++++ b/doc/devhelp/Makefile.am +@@ -63,7 +63,7 @@ + libxml2.devhelp $(HTML_FILES): devhelp.xsl html.xsl $(top_srcdir)/doc/libxml2-api.xml + -@(echo Rebuilding devhelp files) + -@(if [ -x $(XSLTPROC) ] ; then \ +- $(XSLTPROC) --nonet -o $(srcdir)/libxml2.devhelp devhelp.xsl $(top_srcdir)/doc/libxml2-api.xml ; fi ); ++ $(XSLTPROC) --nonet -o $(srcdir)/libxml2.devhelp $(top_srcdir)/doc/devhelp/devhelp.xsl $(top_srcdir)/doc/libxml2-api.xml ; fi ); + + install-data-local: + -@MKDIR_P@ $(DESTDIR)$(DEVHELP_DIR) +--- a/doc/examples/Makefile.am ++++ b/doc/examples/Makefile.am +@@ -5,17 +5,17 @@ + + rebuild: examples.xml index.html + +-examples.xml: index.py *.c ++examples.xml: $(srcdir)/index.py $(srcdir)/*.c + -@($(srcdir)/index.py) + +-index.html: examples.xml examples.xsl +- -@(xsltproc examples.xsl examples.xml && echo "Rebuilt web page" && xmllint --valid --noout index.html) ++index.html: $(srcdir)/examples.xml $(srcdir)/examples.xsl ++ -@(xsltproc $(srcdir)/examples.xsl $(srcdir)/examples.xml && echo "Rebuilt web page" && xmllint --valid --noout index.html) + + install-data-local: + @MKDIR_P@ $(DESTDIR)$(HTML_DIR) + -@INSTALL@ -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(srcdir)/*.xml $(srcdir)/*.xsl $(srcdir)/*.res $(DESTDIR)$(HTML_DIR) + +-EXTRA_DIST=examples.xsl index.py examples.xml writer.xml test3.xml tst.xml test1.xml test2.xml io2.res xpath2.res tree1.res reader4.res io1.res tree2.res reader3.res xpath1.res reader1.res ++EXTRA_DIST=index.html examples.xsl index.py examples.xml writer.xml test3.xml tst.xml test1.xml test2.xml io2.res xpath2.res tree1.res reader4.res io1.res tree2.res reader3.res xpath1.res reader1.res + + noinst_PROGRAMS=xpath2 reader1 reader4 parse2 reader2 parse3 reader3 tree2 parse4 io2 testWriter io1 xpath1 parse1 tree1 + +--- a/doc/Makefile.am ++++ b/doc/Makefile.am +@@ -96,11 +96,11 @@ + -@(cd .. ; $(MAKE) rebuild_testapi) + + +-xmllint.1: xmllint.xml +- -@($(XSLTPROC) --nonet xmllint.xml) ++xmllint.1: $(srcdir)/xmllint.xml ++ -@($(XSLTPROC) --nonet $(srcdir)/xmllint.xml) + +-xmlcatalog.1: xmlcatalog_man.xml +- -@($(XSLTPROC) --nonet xmlcatalog_man.xml) ++xmlcatalog.1: $(srcdir)/xmlcatalog_man.xml ++ -@($(XSLTPROC) --nonet $(srcdir)/xmlcatalog_man.xml) + + clean-local: + rm -f *~ *.bak *.hierarchy *.signals *-unused.txt diff --git a/debian/patches/series b/debian/patches/series index 56dd302..306e703 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1 @@ -01_build-system.patch +01_historical_changes.patch |