diff --git a/textproc/libxml2/Makefile b/textproc/libxml2/Makefile index 366bb9f46f5e..749bc604fe4a 100644 --- a/textproc/libxml2/Makefile +++ b/textproc/libxml2/Makefile @@ -1,76 +1,76 @@ # Created by: Yukihiro Nakai PORTNAME= libxml2 DISTVERSION= 2.9.10 -PORTREVISION?= 3 +PORTREVISION?= 4 CATEGORIES?= textproc gnome MASTER_SITES= http://xmlsoft.org/sources/ DIST_SUBDIR= gnome2 MAINTAINER?= desktop@FreeBSD.org COMMENT?= XML parser library for GNOME LICENSE= MIT TRIO LICENSE_COMB= multi LICENSE_NAME_TRIO= Trio License LICENSE_FILE_MIT= ${WRKSRC}/COPYING LICENSE_FILE_TRIO= ${FILESDIR}/LICENSE.TRIO LICENSE_PERMS_TRIO= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept GNU_CONFIGURE= yes USES+= compiler cpe iconv libtool pathfix pkgconfig shebangfix CPE_VENDOR= xmlsoft USE_LDCONFIG= yes CONFIGURE_ARGS?=--with-iconv=${ICONV_PREFIX} \ --with-html-dir=${PREFIX}/share/doc \ --with-html-subdir=${PORTNAME} \ --without-icu \ --with-lzma=/usr \ --without-python INSTALL_TARGET= install-strip SHEBANG_FILES= *.py */*.py */*/*.py PLIST_SUB+= LIBVERSION=${PORTVERSION} .if !defined(MASTERDIR) OPTIONS_DEFINE= SCHEMA VALIDATION THREADS MEM_DEBUG XMLLINT_HIST THREAD_ALLOC OPTIONS_DEFAULT=SCHEMA VALIDATION THREADS SCHEMA_DESC= XML schema support SCHEMA_CONFIGURE_WITH= schemas VALIDATION_DESC= Validation support VALIDATION_CONFIGURE_OFF= --without-valid THREADS_DESC= Threads support THREADS_CONFIGURE_WITH= threads MEM_DEBUG_DESC= Memory debugging (DEVELOPERS ONLY!) MEM_DEBUG_CONFIGURE_WITH= mem-debug XMLLINT_HIST_DESC= History for xmllint XMLLINT_HIST_CONFIGURE_WITH= history THREAD_ALLOC_DESC= Per-thread memory (DEVELOPERS ONLY!) THREAD_ALLOC_CONFIGURE_WITH= thread-alloc .endif # !defined(MASTERDIR) .if !defined(MASTERDIR) post-install: @${RM} -r ${STAGEDIR}${PREFIX}/share/gtk-doc .endif .include post-patch: .for d in . doc doc/devhelp doc/examples @${REINPLACE_CMD} -e '/^install-data-am:/ s|install-data-local||' \ ${WRKSRC}/${d}/Makefile.in .endfor .for f in catalog.c xmlcatalog.c xmllint.c doc/xmllint.1 @${REINPLACE_CMD} -e \ 's|/etc/xml/catalog|${LOCALBASE}/share/xml/catalog|g; \ s|/etc/sgml/catalog|${LOCALBASE}/share/sgml/catalog|g' \ ${WRKSRC}/${f} .endfor .if ${CHOSEN_COMPILER_TYPE} == gcc @${REINPLACE_CMD} -e 's/ -Wno-array-bounds//' ${WRKSRC}/configure .endif .include diff --git a/textproc/libxml2/files/patch-CVE-2021-3541 b/textproc/libxml2/files/patch-CVE-2021-3541 new file mode 100644 index 000000000000..3ba64fa1d967 --- /dev/null +++ b/textproc/libxml2/files/patch-CVE-2021-3541 @@ -0,0 +1,67 @@ +From 8598060bacada41a0eb09d95c97744ff4e428f8e Mon Sep 17 00:00:00 2001 +From: Daniel Veillard +Date: Thu, 13 May 2021 14:55:12 +0200 +Subject: [PATCH] Patch for security issue CVE-2021-3541 + +This is relapted to parameter entities expansion and following +the line of the billion laugh attack. Somehow in that path the +counting of parameters was missed and the normal algorithm based +on entities "density" was useless. +--- + parser.c | 26 ++++++++++++++++++++++++++ + 1 file changed, 26 insertions(+) + +diff --git parser.c parser.c +index f5e5e169..c9312fa4 100644 +--- parser.c ++++ parser.c +@@ -140,6 +140,7 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, + xmlEntityPtr ent, size_t replacement) + { + size_t consumed = 0; ++ int i; + + if ((ctxt == NULL) || (ctxt->options & XML_PARSE_HUGE)) + return (0); +@@ -177,6 +178,28 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, + rep = NULL; + } + } ++ ++ /* ++ * Prevent entity exponential check, not just replacement while ++ * parsing the DTD ++ * The check is potentially costly so do that only once in a thousand ++ */ ++ if ((ctxt->instate == XML_PARSER_DTD) && (ctxt->nbentities > 10000) && ++ (ctxt->nbentities % 1024 == 0)) { ++ for (i = 0;i < ctxt->inputNr;i++) { ++ consumed += ctxt->inputTab[i]->consumed + ++ (ctxt->inputTab[i]->cur - ctxt->inputTab[i]->base); ++ } ++ if (ctxt->nbentities > consumed * XML_PARSER_NON_LINEAR) { ++ xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); ++ ctxt->instate = XML_PARSER_EOF; ++ return (1); ++ } ++ consumed = 0; ++ } ++ ++ ++ + if (replacement != 0) { + if (replacement < XML_MAX_TEXT_LENGTH) + return(0); +@@ -7963,6 +7986,9 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt) + xmlChar start[4]; + xmlCharEncoding enc; + ++ if (xmlParserEntityCheck(ctxt, 0, entity, 0)) ++ return; ++ + if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) && + ((ctxt->options & XML_PARSE_NOENT) == 0) && + ((ctxt->options & XML_PARSE_DTDVALID) == 0) && +-- +2.31.1 +