diff options
-rw-r--r-- | textproc/libxml2/Makefile | 36 | ||||
-rw-r--r-- | textproc/libxml2/files/patch-Makefile.in | 2 | ||||
-rw-r--r-- | textproc/libxml2/files/patch-include_libxml_parser.h | 10 | ||||
-rw-r--r-- | textproc/libxml2/files/patch-libxml-2.0-uninstalled.pc.in | 9 | ||||
-rw-r--r-- | textproc/libxml2/files/patch-libxml-2.0.pc.in | 9 | ||||
-rw-r--r-- | textproc/libxml2/files/patch-parser.c | 343 | ||||
-rw-r--r-- | textproc/libxml2/files/patch-parserInternals.c | 11 | ||||
-rw-r--r-- | textproc/libxml2/files/patch-python_Makefile.in (renamed from textproc/libxml2/files/patch-python_Makefile) | 0 | ||||
-rw-r--r-- | textproc/libxml2/files/patch-xml2Conf.sh.in | 2 | ||||
-rw-r--r-- | textproc/py-libxml2/Makefile | 5 |
10 files changed, 407 insertions, 20 deletions
diff --git a/textproc/libxml2/Makefile b/textproc/libxml2/Makefile index 4086aca4d..12b7c8e60 100644 --- a/textproc/libxml2/Makefile +++ b/textproc/libxml2/Makefile @@ -1,19 +1,13 @@ # Created by: Yukihiro Nakai <Nakai@technologist.com> # $FreeBSD$ # $MCom: ports/trunk/textproc/libxml2/Makefile 17268 2013-04-01 05:13:11Z marcus $ -# -# WITHOUT_SCHEMA disable XML schema support -# WITHOUT_THREADS disable threads support -# WITH_MEM_DEBUG enable memory debugging (DEVELOPERS ONLY!) -# WITH_XMLLINT_HIST enable history for xmllint -# WITH_THREAD_ALLOC enable per-thread memory (DEVELOPERS ONLY!) -# PORTNAME= libxml2 PORTVERSION= 2.8.0 -PORTREVISION?= 0 +PORTREVISION?= 2 CATEGORIES?= textproc gnome MASTER_SITES= ftp://xmlsoft.org/libxml2/ \ + http://xmlsoft.org/sources/ \ ftp://gd.tuwien.ac.at/pub/libxml/ DIST_SUBDIR= gnome2 @@ -22,7 +16,6 @@ COMMENT?= XML parser library for GNOME .if !defined(REFERENCE_PORT) -USE_CSTD= gnu89 USE_GMAKE= yes MAKE_JOBS_SAFE= yes GNU_CONFIGURE= yes @@ -31,34 +24,43 @@ USE_LDCONFIG= yes CONFIGURE_ARGS?=--with-iconv=${LOCALBASE} \ --with-html-dir=${PREFIX}/share/doc \ --with-html-subdir=${PORTNAME} \ + --with-lzma=/usr \ --without-python -CPPFLAGS+= -I${LOCALBASE}/include -LDFLAGS+= -L${LOCALBASE}/lib .if !defined(MASTERDIR) MAN1= xml2-config.1 xmllint.1 xmlcatalog.1 MAN3= libxml.3 -.endif -.if defined(WITHOUT_SCHEMA) +OPTIONS_DEFINE= SCHEMA THREADS MEM_DEBUG XMLLINT_HIST THREAD_ALLOC +OPTIONS_DEFAULT=SCHEMA THREADS +SCHEMA_DESC= XML schema support +THREADS_DESC= Threads support +MEM_DEBUG_DESC= Memory debugging (DEVELOPERS ONLY!) +XMLLINT_HIST_DESC= History for xmllint +THREAD_ALLOC_DESC= Per-thread memory (DEVELOPERS ONLY!) + +.include <bsd.port.options.mk> + +.if ! ${PORT_OPTIONS:MSCHEMA} CONFIGURE_ARGS+= --without-schemas .endif -.if defined(WITHOUT_THREADS) +.if ! ${PORT_OPTIONS:MTHREADS} CONFIGURE_ARGS+= --without-threads .endif -.if defined(WITH_MEM_DEBUG) +.if ${PORT_OPTIONS:MMEM_DEBUG} CONFIGURE_ARGS+= --with-mem-debug .endif -.if defined(WITH_XMLLINT_HIST) +.if ${PORT_OPTIONS:MXMLLINT_HIST} CONFIGURE_ARGS+= --with-history .endif -.if defined(WITH_THREAD_ALLOC) +.if ${PORT_OPTIONS:MTHREAD_ALLOC} CONFIGURE_ARGS+= --with-thread-alloc .endif +.endif # !defined(MASTERDIR) post-patch: .for d in . doc doc/devhelp doc/examples diff --git a/textproc/libxml2/files/patch-Makefile.in b/textproc/libxml2/files/patch-Makefile.in index 60dd2ee07..df4c9761d 100644 --- a/textproc/libxml2/files/patch-Makefile.in +++ b/textproc/libxml2/files/patch-Makefile.in @@ -1,3 +1,5 @@ + $FreeBSD$ + --- Makefile.in.orig 2012-08-16 19:38:10.000000000 +0200 +++ Makefile.in 2012-08-16 19:39:09.000000000 +0200 @@ -586,7 +586,7 @@ diff --git a/textproc/libxml2/files/patch-include_libxml_parser.h b/textproc/libxml2/files/patch-include_libxml_parser.h new file mode 100644 index 000000000..03632be45 --- /dev/null +++ b/textproc/libxml2/files/patch-include_libxml_parser.h @@ -0,0 +1,10 @@ +--- include/libxml/parser.h.orig 2012-05-15 03:09:43.000000000 +0000 ++++ include/libxml/parser.h 2013-03-13 09:42:57.000000000 +0000 +@@ -310,6 +310,7 @@ + xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */ + + int input_id; /* we need to label inputs */ ++ unsigned long sizeentcopy; /* volume of entity copy */ + }; + + /** diff --git a/textproc/libxml2/files/patch-libxml-2.0-uninstalled.pc.in b/textproc/libxml2/files/patch-libxml-2.0-uninstalled.pc.in new file mode 100644 index 000000000..d8e7102df --- /dev/null +++ b/textproc/libxml2/files/patch-libxml-2.0-uninstalled.pc.in @@ -0,0 +1,9 @@ +--- libxml-2.0-uninstalled.pc.in.orig 2009-07-30 11:24:34.000000000 -0400 ++++ libxml-2.0-uninstalled.pc.in 2013-04-09 15:37:18.000000000 -0400 +@@ -8,5 +8,5 @@ + Version: @VERSION@ + Description: libXML library version2. + Requires: +-Libs: -L${libdir} -lxml2 @THREAD_LIBS@ @Z_LIBS@ @ICONV_LIBS@ @M_LIBS@ @LIBS@ ++Libs: -L${libdir} -lxml2 @THREAD_LIBS@ @Z_LIBS@ @LZMA_LIBS@ @ICONV_LIBS@ @M_LIBS@ @LIBS@ + Cflags: -I${includedir} @XML_INCLUDEDIR@ @XML_CFLAGS@ diff --git a/textproc/libxml2/files/patch-libxml-2.0.pc.in b/textproc/libxml2/files/patch-libxml-2.0.pc.in new file mode 100644 index 000000000..37f94ce3d --- /dev/null +++ b/textproc/libxml2/files/patch-libxml-2.0.pc.in @@ -0,0 +1,9 @@ +--- libxml-2.0.pc.in.orig 2010-05-14 11:26:41.000000000 -0400 ++++ libxml-2.0.pc.in 2013-04-09 15:35:53.000000000 -0400 +@@ -9,5 +9,5 @@ + Description: libXML library version2. + Requires: + Libs: -L${libdir} -lxml2 +-Libs.private: @THREAD_LIBS@ @Z_LIBS@ @ICONV_LIBS@ @M_LIBS@ @WIN32_EXTRA_LIBADD@ @LIBS@ ++Libs.private: @THREAD_LIBS@ @Z_LIBS@ @LZMA_LIBS@ @ICONV_LIBS@ @M_LIBS@ @WIN32_EXTRA_LIBADD@ @LIBS@ + Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@ diff --git a/textproc/libxml2/files/patch-parser.c b/textproc/libxml2/files/patch-parser.c new file mode 100644 index 000000000..1316d921d --- /dev/null +++ b/textproc/libxml2/files/patch-parser.c @@ -0,0 +1,343 @@ + +--- parser.c.orig 2013-03-13 09:36:07.000000000 +0000 ++++ parser.c 2013-03-13 09:35:54.000000000 +0000 +@@ -40,6 +40,7 @@ + #endif + + #include <stdlib.h> ++#include <limits.h> + #include <string.h> + #include <stdarg.h> + #include <libxml/xmlmemory.h> +@@ -117,16 +118,33 @@ + * parser option. + */ + static int +-xmlParserEntityCheck(xmlParserCtxtPtr ctxt, unsigned long size, +- xmlEntityPtr ent) ++xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, ++ xmlEntityPtr ent, size_t replacement) + { +- unsigned long consumed = 0; ++ size_t consumed = 0; + + if ((ctxt == NULL) || (ctxt->options & XML_PARSE_HUGE)) + return (0); + if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) + return (1); +- if (size != 0) { ++ if (replacement != 0) { ++ if (replacement < XML_MAX_TEXT_LENGTH) ++ return(0); ++ ++ /* ++ * If the volume of entity copy reaches 10 times the ++ * amount of parsed data and over the large text threshold ++ * then that's very likely to be an abuse. ++ */ ++ if (ctxt->input != NULL) { ++ consumed = ctxt->input->consumed + ++ (ctxt->input->cur - ctxt->input->base); ++ } ++ consumed += ctxt->sizeentities; ++ ++ if (replacement < XML_PARSER_NON_LINEAR * consumed) ++ return(0); ++ } else if (size != 0) { + /* + * Do the check based on the replacement size of the entity + */ +@@ -172,7 +190,6 @@ + */ + return (0); + } +- + xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); + return (1); + } +@@ -2589,15 +2606,17 @@ + + /* + * Macro used to grow the current buffer. ++ * buffer##_size is expected to be a size_t ++ * mem_error: is expected to handle memory allocation failures + */ + #define growBuffer(buffer, n) { \ + xmlChar *tmp; \ +- buffer##_size *= 2; \ +- buffer##_size += n; \ +- tmp = (xmlChar *) \ +- xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \ ++ size_t new_size = buffer##_size * 2 + n; \ ++ if (new_size < buffer##_size) goto mem_error; \ ++ tmp = (xmlChar *) xmlRealloc(buffer, new_size); \ + if (tmp == NULL) goto mem_error; \ + buffer = tmp; \ ++ buffer##_size = new_size; \ + } + + /** +@@ -2623,14 +2642,14 @@ + xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, + int what, xmlChar end, xmlChar end2, xmlChar end3) { + xmlChar *buffer = NULL; +- int buffer_size = 0; ++ size_t buffer_size = 0; ++ size_t nbchars = 0; + + xmlChar *current = NULL; + xmlChar *rep = NULL; + const xmlChar *last; + xmlEntityPtr ent; + int c,l; +- int nbchars = 0; + + if ((ctxt == NULL) || (str == NULL) || (len < 0)) + return(NULL); +@@ -2647,7 +2666,7 @@ + * allocate a translation buffer. + */ + buffer_size = XML_PARSER_BIG_BUFFER_SIZE; +- buffer = (xmlChar *) xmlMallocAtomic(buffer_size * sizeof(xmlChar)); ++ buffer = (xmlChar *) xmlMallocAtomic(buffer_size); + if (buffer == NULL) goto mem_error; + + /* +@@ -2667,7 +2686,7 @@ + if (val != 0) { + COPY_BUF(0,buffer,nbchars,val); + } +- if (nbchars > buffer_size - XML_PARSER_BUFFER_SIZE) { ++ if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) { +@@ -2685,7 +2704,7 @@ + (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { + if (ent->content != NULL) { + COPY_BUF(0,buffer,nbchars,ent->content[0]); +- if (nbchars > buffer_size - XML_PARSER_BUFFER_SIZE) { ++ if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } else { +@@ -2702,9 +2721,8 @@ + current = rep; + while (*current != 0) { /* non input consuming loop */ + buffer[nbchars++] = *current++; +- if (nbchars > +- buffer_size - XML_PARSER_BUFFER_SIZE) { +- if (xmlParserEntityCheck(ctxt, nbchars, ent)) ++ if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { ++ if (xmlParserEntityCheck(ctxt, nbchars, ent, 0)) + goto int_error; + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } +@@ -2717,7 +2735,7 @@ + const xmlChar *cur = ent->name; + + buffer[nbchars++] = '&'; +- if (nbchars > buffer_size - i - XML_PARSER_BUFFER_SIZE) { ++ if (nbchars + i + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, i + XML_PARSER_BUFFER_SIZE); + } + for (;i > 0;i--) +@@ -2745,9 +2763,8 @@ + current = rep; + while (*current != 0) { /* non input consuming loop */ + buffer[nbchars++] = *current++; +- if (nbchars > +- buffer_size - XML_PARSER_BUFFER_SIZE) { +- if (xmlParserEntityCheck(ctxt, nbchars, ent)) ++ if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { ++ if (xmlParserEntityCheck(ctxt, nbchars, ent, 0)) + goto int_error; + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } +@@ -2759,8 +2776,8 @@ + } else { + COPY_BUF(l,buffer,nbchars,c); + str += l; +- if (nbchars > buffer_size - XML_PARSER_BUFFER_SIZE) { +- growBuffer(buffer, XML_PARSER_BUFFER_SIZE); ++ if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { ++ growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } + if (str < last) +@@ -3764,8 +3781,8 @@ + xmlChar limit = 0; + xmlChar *buf = NULL; + xmlChar *rep = NULL; +- int len = 0; +- int buf_size = 0; ++ size_t len = 0; ++ size_t buf_size = 0; + int c, l, in_space = 0; + xmlChar *current = NULL; + xmlEntityPtr ent; +@@ -3787,7 +3804,7 @@ + * allocate a translation buffer. + */ + buf_size = XML_PARSER_BUFFER_SIZE; +- buf = (xmlChar *) xmlMallocAtomic(buf_size * sizeof(xmlChar)); ++ buf = (xmlChar *) xmlMallocAtomic(buf_size); + if (buf == NULL) goto mem_error; + + /* +@@ -3804,7 +3821,7 @@ + + if (val == '&') { + if (ctxt->replaceEntities) { +- if (len > buf_size - 10) { ++ if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + buf[len++] = '&'; +@@ -3813,7 +3830,7 @@ + * The reparsing will be done in xmlStringGetNodeList() + * called by the attribute() function in SAX.c + */ +- if (len > buf_size - 10) { ++ if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + buf[len++] = '&'; +@@ -3823,7 +3840,7 @@ + buf[len++] = ';'; + } + } else if (val != 0) { +- if (len > buf_size - 10) { ++ if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + len += xmlCopyChar(0, &buf[len], val); +@@ -3835,7 +3852,7 @@ + ctxt->nbentities += ent->owner; + if ((ent != NULL) && + (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { +- if (len > buf_size - 10) { ++ if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + if ((ctxt->replaceEntities == 0) && +@@ -3863,7 +3880,7 @@ + current++; + } else + buf[len++] = *current++; +- if (len > buf_size - 10) { ++ if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + } +@@ -3871,7 +3888,7 @@ + rep = NULL; + } + } else { +- if (len > buf_size - 10) { ++ if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + if (ent->content != NULL) +@@ -3899,7 +3916,7 @@ + * Just output the reference + */ + buf[len++] = '&'; +- while (len > buf_size - i - 10) { ++ while (len + i + 10 > buf_size) { + growBuffer(buf, i + 10); + } + for (;i > 0;i--) +@@ -3912,7 +3929,7 @@ + if ((len != 0) || (!normalize)) { + if ((!normalize) || (!in_space)) { + COPY_BUF(l,buf,len,0x20); +- while (len > buf_size - 10) { ++ while (len + 10 > buf_size) { + growBuffer(buf, 10); + } + } +@@ -3921,7 +3938,7 @@ + } else { + in_space = 0; + COPY_BUF(l,buf,len,c); +- if (len > buf_size - 10) { ++ if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + } +@@ -3931,7 +3948,7 @@ + c = CUR_CHAR(l); + } + if ((in_space) && (normalize)) { +- while (buf[len - 1] == 0x20) len--; ++ while ((len > 0) && (buf[len - 1] == 0x20)) len--; + } + buf[len] = 0; + if (RAW == '<') { +@@ -3946,7 +3963,18 @@ + } + } else + NEXT; +- if (attlen != NULL) *attlen = len; ++ ++ /* ++ * There we potentially risk an overflow, don't allow attribute value of ++ * lenght more than INT_MAX it is a very reasonnable assumption ! ++ */ ++ if (len >= INT_MAX) { ++ xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, ++ "AttValue lenght too long\n"); ++ goto mem_error; ++ } ++ ++ if (attlen != NULL) *attlen = (int) len; + return(buf); + + mem_error: +@@ -6964,7 +6992,7 @@ + xmlFreeNodeList(list); + return; + } +- if (xmlParserEntityCheck(ctxt, 0, ent)) { ++ if (xmlParserEntityCheck(ctxt, 0, ent, 0)) { + xmlFreeNodeList(list); + return; + } +@@ -7124,6 +7152,13 @@ + xmlNodePtr nw = NULL, cur, firstChild = NULL; + + /* ++ * We are copying here, make sure there is no abuse ++ */ ++ ctxt->sizeentcopy += ent->length; ++ if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy)) ++ return; ++ ++ /* + * when operating on a reader, the entities definitions + * are always owning the entities subtree. + if (ctxt->parseMode == XML_PARSE_READER) +@@ -7163,6 +7198,14 @@ + } else if (list == NULL) { + xmlNodePtr nw = NULL, cur, next, last, + firstChild = NULL; ++ ++ /* ++ * We are copying here, make sure there is no abuse ++ */ ++ ctxt->sizeentcopy += ent->length; ++ if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy)) ++ return; ++ + /* + * Copy the entity child list and make it the new + * entity child list. The goal is to make sure any +@@ -14343,6 +14386,7 @@ + ctxt->catalogs = NULL; + ctxt->nbentities = 0; + ctxt->sizeentities = 0; ++ ctxt->sizeentcopy = 0; + xmlInitNodeInfoSeq(&ctxt->node_seq); + + if (ctxt->attsDefault != NULL) { diff --git a/textproc/libxml2/files/patch-parserInternals.c b/textproc/libxml2/files/patch-parserInternals.c new file mode 100644 index 000000000..ac0123de0 --- /dev/null +++ b/textproc/libxml2/files/patch-parserInternals.c @@ -0,0 +1,11 @@ +--- parserInternals.c.orig 2012-05-15 03:16:38.000000000 +0000 ++++ parserInternals.c 2013-03-13 09:35:54.000000000 +0000 +@@ -1761,6 +1761,8 @@ + ctxt->charset = XML_CHAR_ENCODING_UTF8; + ctxt->catalogs = NULL; + ctxt->nbentities = 0; ++ ctxt->sizeentities = 0; ++ ctxt->sizeentcopy = 0; + ctxt->input_id = 1; + xmlInitNodeInfoSeq(&ctxt->node_seq); + return(0); diff --git a/textproc/libxml2/files/patch-python_Makefile b/textproc/libxml2/files/patch-python_Makefile.in index 564271951..564271951 100644 --- a/textproc/libxml2/files/patch-python_Makefile +++ b/textproc/libxml2/files/patch-python_Makefile.in diff --git a/textproc/libxml2/files/patch-xml2Conf.sh.in b/textproc/libxml2/files/patch-xml2Conf.sh.in index 66b74d3be..e07940d12 100644 --- a/textproc/libxml2/files/patch-xml2Conf.sh.in +++ b/textproc/libxml2/files/patch-xml2Conf.sh.in @@ -1,4 +1,6 @@ +$FreeBSD$ + --- xml2Conf.sh.in 2001/05/19 19:57:43 1.1 +++ xml2Conf.sh.in 2001/05/19 19:59:40 @@ -1,6 +1,12 @@ diff --git a/textproc/py-libxml2/Makefile b/textproc/py-libxml2/Makefile index 018242cba..fa560f2d4 100644 --- a/textproc/py-libxml2/Makefile +++ b/textproc/py-libxml2/Makefile @@ -15,11 +15,10 @@ INSTALL_WRKSRC= ${BUILD_WRKSRC} DESCR= ${.CURDIR}/pkg-descr PLIST= ${.CURDIR}/pkg-plist -USES= pathfix -USE_GNOME= libxml2 +USE_GNOME+= libxml2 USE_PYTHON= yes CPPFLAGS+= `${PYTHON_VERSION}-config --cflags` -LDFLAGS+= `${PYTHON_VERSION}-config --libs` +LDFLAGS+= -L${LOCALBASE}/lib `${PYTHON_VERSION}-config --libs` CONFIGURE_ARGS= --with-iconv=${LOCALBASE} \ --with-html-dir=${PREFIX}/share/doc \ --with-html-subdir=${PORTNAME} \ |