View | Details | Raw Unified | Return to bug 256617
Collapse All | Expand All

(-)b/textproc/libxslt/Makefile (-18 / +18 lines)
Lines 2-40 Link Here
2
2
3
PORTNAME=	libxslt
3
PORTNAME=	libxslt
4
DISTVERSION=	1.1.34
4
DISTVERSION=	1.1.34
5
PORTREVISION=	1
5
PORTREVISION=	2
6
CATEGORIES?=	textproc gnome
6
CATEGORIES=	textproc gnome
7
MASTER_SITES=	http://xmlsoft.org/sources/ \
7
MASTER_SITES=	http://xmlsoft.org/sources/ \
8
		https://mirror.umd.edu/xbmc/build-deps/sources/
8
		https://mirror.umd.edu/xbmc/build-deps/sources/
9
DIST_SUBDIR=	gnome2
9
DIST_SUBDIR=	gnome2
10
10
11
MAINTAINER?=	desktop@FreeBSD.org
11
MAINTAINER=	desktop@FreeBSD.org
12
COMMENT?=	The XSLT C library for GNOME
12
COMMENT=	XML stylesheet transformation library
13
13
14
USES+=		cpe gmake gnome localbase libtool pathfix
14
LICENSE=	MIT
15
LICENSE_FILE=	${WRKSRC}/COPYING
16
17
USES=		cpe gmake gnome localbase libtool pathfix
15
CPE_VENDOR=	xmlsoft
18
CPE_VENDOR=	xmlsoft
16
GNU_CONFIGURE=	yes
19
GNU_CONFIGURE=	yes
17
INSTALL_TARGET=	install-strip
20
USE_GNOME=	libxml2
18
USE_LDCONFIG=	yes
21
USE_LDCONFIG=	yes
19
USE_GNOME?=	libxml2
20
CONFIGURE_ARGS?=--with-html-dir=${PREFIX}/share/doc \
21
		--without-python
22
22
23
LICENSE=	MIT
23
CONFIGURE_ARGS=	--with-html-dir=${PREFIX}/share/doc \
24
		--without-python
24
25
25
.if defined(MASTERDIR)
26
INSTALL_TARGET=	install-strip
26
_SLAVE_PORT=	yes
27
TEST_TARGET=	check
27
.else
28
28
29
OPTIONS_DEFINE=	MEM_DEBUG CRYPTO
29
OPTIONS_DEFINE=	CRYPTO MEM_DEBUG
30
OPTIONS_DEFAULT=CRYPTO
30
OPTIONS_DEFAULT=CRYPTO
31
32
CRYPTO_DESC=	Enable crypto support
31
MEM_DEBUG_DESC=	Enable memory debugging
33
MEM_DEBUG_DESC=	Enable memory debugging
32
CRYPTO_DESC=	Enable crypto support for exslt
33
.endif
34
34
35
MEM_DEBUG_CONFIGURE_ON=	--with-mem-debug
36
CRYPTO_CONFIGURE_WITH=	crypto
37
CRYPTO_LIB_DEPENDS=	libgcrypt.so:security/libgcrypt
35
CRYPTO_LIB_DEPENDS=	libgcrypt.so:security/libgcrypt
36
CRYPTO_CONFIGURE_WITH=	crypto
37
MEM_DEBUG_CONFIGURE_ON=	--with-mem-debug
38
38
39
post-patch:
39
post-patch:
40
	@${REINPLACE_CMD} -e '/^install-data-am:/ s|install-data-local||' \
40
	@${REINPLACE_CMD} -e '/^install-data-am:/ s|install-data-local||' \
(-)b/textproc/libxslt/files/patch-git-01-9ae2f94df1721e002941b40665efb762aefcea1a (+37 lines)
Added Link Here
1
From 9ae2f94df1721e002941b40665efb762aefcea1a Mon Sep 17 00:00:00 2001
2
From: Nick Wellnhofer <wellnhofer@aevum.de>
3
Date: Mon, 17 Aug 2020 03:42:11 +0200
4
Subject: [PATCH] Stop using maxParserDepth XPath limit
5
6
This will be removed again from libxml2.
7
---
8
 tests/fuzz/fuzz.c | 6 ++----
9
 1 file changed, 2 insertions(+), 4 deletions(-)
10
11
diff --git a/tests/fuzz/fuzz.c b/tests/fuzz/fuzz.c
12
index f502ca2c..75234ad6 100644
13
--- tests/fuzz/fuzz.c
14
+++ tests/fuzz/fuzz.c
15
@@ -183,8 +183,7 @@ xsltFuzzXPathInit(int *argc_p ATTRIBUTE_UNUSED, char ***argv_p,
16
     xpctxt = tctxt->xpathCtxt;
17
 
18
     /* Resource limits to avoid timeouts and call stack overflows */
19
-    xpctxt->maxParserDepth = 15;
20
-    xpctxt->maxDepth = 100;
21
+    xpctxt->maxDepth = 500;
22
     xpctxt->opLimit = 500000;
23
 
24
     /* Test namespaces used in xpath.xml */
25
@@ -317,8 +316,7 @@ xsltFuzzXsltInit(int *argc_p ATTRIBUTE_UNUSED, char ***argv_p,
26
 
27
 static void
28
 xsltSetXPathResourceLimits(xmlXPathContextPtr ctxt) {
29
-    ctxt->maxParserDepth = 15;
30
-    ctxt->maxDepth = 100;
31
+    ctxt->maxDepth = 200;
32
     ctxt->opLimit = 100000;
33
 }
34
 
35
-- 
36
GitLab
37
(-)b/textproc/libxslt/files/patch-git-02-824657768aea2cce9c23e72ba8085cb5e44350c7 (+42 lines)
Added Link Here
1
From 824657768aea2cce9c23e72ba8085cb5e44350c7 Mon Sep 17 00:00:00 2001
2
From: Nick Wellnhofer <wellnhofer@aevum.de>
3
Date: Mon, 17 Aug 2020 04:27:13 +0200
4
Subject: [PATCH] Transfer XPath limits to XPtr context
5
6
Expressions like document('doc.xml#xpointer(evil_expr)') ignored the
7
XPath limits.
8
---
9
 libxslt/functions.c | 14 +++++++++++++-
10
 1 file changed, 13 insertions(+), 1 deletion(-)
11
12
diff --git a/libxslt/functions.c b/libxslt/functions.c
13
index b350545a..975ea790 100644
14
--- libxslt/functions.c
15
+++ libxslt/functions.c
16
@@ -178,10 +178,22 @@ xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar* URI)
17
 	goto out_fragment;
18
     }
19
 
20
+#if LIBXML_VERSION >= 20911 || \
21
+    defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
22
+    xptrctxt->opLimit = ctxt->context->opLimit;
23
+    xptrctxt->opCount = ctxt->context->opCount;
24
+    xptrctxt->maxDepth = ctxt->context->maxDepth - ctxt->context->depth;
25
+
26
+    resObj = xmlXPtrEval(fragment, xptrctxt);
27
+
28
+    ctxt->context->opCount = xptrctxt->opCount;
29
+#else
30
     resObj = xmlXPtrEval(fragment, xptrctxt);
31
-    xmlXPathFreeContext(xptrctxt);
32
 #endif
33
 
34
+    xmlXPathFreeContext(xptrctxt);
35
+#endif /* LIBXML_XPTR_ENABLED */
36
+
37
     if (resObj == NULL)
38
 	goto out_fragment;
39
 
40
-- 
41
GitLab
42
(-)b/textproc/libxslt/files/patch-git-03-77c26bad0433541f486b1e7ced44ca9979376908 (+70 lines)
Added Link Here
1
From 77c26bad0433541f486b1e7ced44ca9979376908 Mon Sep 17 00:00:00 2001
2
From: Nick Wellnhofer <wellnhofer@aevum.de>
3
Date: Wed, 26 Aug 2020 00:34:38 +0200
4
Subject: [PATCH] Don't set maxDepth in XPath contexts
5
6
The maximum recursion depth is hardcoded in libxml2 now.
7
---
8
 libxslt/functions.c |  2 +-
9
 tests/fuzz/fuzz.c   | 11 ++---------
10
 2 files changed, 3 insertions(+), 10 deletions(-)
11
12
diff --git a/libxslt/functions.c b/libxslt/functions.c
13
index 975ea790..7887dda7 100644
14
--- libxslt/functions.c
15
+++ libxslt/functions.c
16
@@ -182,7 +182,7 @@ xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar* URI)
17
     defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
18
     xptrctxt->opLimit = ctxt->context->opLimit;
19
     xptrctxt->opCount = ctxt->context->opCount;
20
-    xptrctxt->maxDepth = ctxt->context->maxDepth - ctxt->context->depth;
21
+    xptrctxt->depth = ctxt->context->depth;
22
 
23
     resObj = xmlXPtrEval(fragment, xptrctxt);
24
 
25
diff --git a/tests/fuzz/fuzz.c b/tests/fuzz/fuzz.c
26
index 75234ad6..780c2d41 100644
27
--- tests/fuzz/fuzz.c
28
+++ tests/fuzz/fuzz.c
29
@@ -183,7 +183,6 @@ xsltFuzzXPathInit(int *argc_p ATTRIBUTE_UNUSED, char ***argv_p,
30
     xpctxt = tctxt->xpathCtxt;
31
 
32
     /* Resource limits to avoid timeouts and call stack overflows */
33
-    xpctxt->maxDepth = 500;
34
     xpctxt->opLimit = 500000;
35
 
36
     /* Test namespaces used in xpath.xml */
37
@@ -314,12 +313,6 @@ xsltFuzzXsltInit(int *argc_p ATTRIBUTE_UNUSED, char ***argv_p,
38
     return 0;
39
 }
40
 
41
-static void
42
-xsltSetXPathResourceLimits(xmlXPathContextPtr ctxt) {
43
-    ctxt->maxDepth = 200;
44
-    ctxt->opLimit = 100000;
45
-}
46
-
47
 xmlChar *
48
 xsltFuzzXslt(const char *data, size_t size) {
49
     xmlDocPtr xsltDoc;
50
@@ -349,7 +342,7 @@ xsltFuzzXslt(const char *data, size_t size) {
51
         xmlFreeDoc(xsltDoc);
52
         return NULL;
53
     }
54
-    xsltSetXPathResourceLimits(sheet->xpathCtxt);
55
+    sheet->xpathCtxt->opLimit = 100000;
56
     sheet->xpathCtxt->opCount = 0;
57
     if (xsltParseStylesheetUser(sheet, xsltDoc) != 0) {
58
         xsltFreeStylesheet(sheet);
59
@@ -361,7 +354,7 @@ xsltFuzzXslt(const char *data, size_t size) {
60
     xsltSetCtxtSecurityPrefs(sec, ctxt);
61
     ctxt->maxTemplateDepth = 100;
62
     ctxt->opLimit = 20000;
63
-    xsltSetXPathResourceLimits(ctxt->xpathCtxt);
64
+    ctxt->xpathCtxt->opLimit = 100000;
65
     ctxt->xpathCtxt->opCount = sheet->xpathCtxt->opCount;
66
 
67
     result = xsltApplyStylesheetUser(sheet, doc, NULL, NULL, NULL, ctxt);
68
-- 
69
GitLab
70

Return to bug 256617