View | Details | Raw Unified | Return to bug 251040 | Differences between
and this patch

Collapse All | Expand All

(-)b/textproc/libxml2/Makefile (-6 / +6 lines)
Lines 3-19 Link Here
3
3
4
PORTNAME=	libxml2
4
PORTNAME=	libxml2
5
DISTVERSION=	2.9.10
5
DISTVERSION=	2.9.10
6
PORTREVISION?=	1
6
PORTREVISION?=	2
7
CATEGORIES?=	textproc gnome
7
CATEGORIES?=	textproc gnome
8
MASTER_SITES=	http://xmlsoft.org/sources/
8
MASTER_SITES=	http://xmlsoft.org/sources/
9
DIST_SUBDIR=	gnome2
9
DIST_SUBDIR=	gnome2
10
10
11
# CVE-2019-20388, CVE-2020-7595, CVE-2020-24977, Python 3.9 support
11
# CVE-2019-20388, CVE-2020-7595, CVE-2020-24977, Python 3.9 support
12
PATCH_SITES=	https://gitlab.gnome.org/GNOME/libxml2/commit/
12
#PATCH_SITES=	https://gitlab.gnome.org/GNOME/libxml2/commit/
13
PATCHFILES=	7ffcd44d7e6c46704f8af0321d9314cd26e0e18a.patch:-p1 \
13
#PATCHFILES=	7ffcd44d7e6c46704f8af0321d9314cd26e0e18a.patch:-p1 \
14
		0e1a49c8907645d2e155f0d89d4d9895ac5112b5.patch:-p1 \
14
#		0e1a49c8907645d2e155f0d89d4d9895ac5112b5.patch:-p1 \
15
		50f06b3efb638efb0abd95dc62dca05ae67882c2.patch:-p1 \
15
#		50f06b3efb638efb0abd95dc62dca05ae67882c2.patch:-p1 \
16
		edc7b6abb0c125eeb888748c334897f60aab0854.patch:-p1
16
#		edc7b6abb0c125eeb888748c334897f60aab0854.patch:-p1
17
17
18
MAINTAINER?=	desktop@FreeBSD.org
18
MAINTAINER?=	desktop@FreeBSD.org
19
COMMENT?=	XML parser library for GNOME
19
COMMENT?=	XML parser library for GNOME
(-)b/textproc/libxml2/files/patch-CVE-2019-20388 (+33 lines)
Added Link Here
1
From 7ffcd44d7e6c46704f8af0321d9314cd26e0e18a Mon Sep 17 00:00:00 2001
2
From: Zhipeng Xie <xiezhipeng1@huawei.com>
3
Date: Tue, 20 Aug 2019 16:33:06 +0800
4
Subject: [PATCH] Fix memory leak in xmlSchemaValidateStream
5
6
When ctxt->schema is NULL, xmlSchemaSAXPlug->xmlSchemaPreRun
7
alloc a new schema for ctxt->schema and set vctxt->xsiAssemble
8
to 1. Then xmlSchemaVStart->xmlSchemaPreRun initialize
9
vctxt->xsiAssemble to 0 again which cause the alloced schema
10
can not be freed anymore.
11
12
Found with libFuzzer.
13
14
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
15
---
16
 xmlschemas.c | 1 -
17
 1 file changed, 1 deletion(-)
18
19
diff --git a/xmlschemas.c b/xmlschemas.c
20
index 301c8449..39d92182 100644
21
--- xmlschemas.c
22
+++ xmlschemas.c
23
@@ -28090,7 +28090,6 @@ xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) {
24
     vctxt->nberrors = 0;
25
     vctxt->depth = -1;
26
     vctxt->skipDepth = -1;
27
-    vctxt->xsiAssemble = 0;
28
     vctxt->hasKeyrefs = 0;
29
 #ifdef ENABLE_IDC_NODE_TABLES_TEST
30
     vctxt->createIDCNodeTables = 1;
31
-- 
32
GitLab
33
(-)b/textproc/libxml2/files/patch-CVE-2020-24977 (+36 lines)
Added Link Here
1
From 50f06b3efb638efb0abd95dc62dca05ae67882c2 Mon Sep 17 00:00:00 2001
2
From: Nick Wellnhofer <wellnhofer@aevum.de>
3
Date: Fri, 7 Aug 2020 21:54:27 +0200
4
Subject: [PATCH] Fix out-of-bounds read with 'xmllint --htmlout'
5
6
Make sure that truncated UTF-8 sequences don't cause an out-of-bounds
7
array access.
8
9
Thanks to @SuhwanSong and the Agency for Defense Development (ADD) for
10
the report.
11
12
Fixes #178.
13
---
14
 xmllint.c | 6 ++++++
15
 1 file changed, 6 insertions(+)
16
17
diff --git a/xmllint.c b/xmllint.c
18
index f6a8e463..c647486f 100644
19
--- xmllint.c
20
+++ xmllint.c
21
@@ -528,6 +528,12 @@ static void
22
 xmlHTMLEncodeSend(void) {
23
     char *result;
24
 
25
+    /*
26
+     * xmlEncodeEntitiesReentrant assumes valid UTF-8, but the buffer might
27
+     * end with a truncated UTF-8 sequence. This is a hack to at least avoid
28
+     * an out-of-bounds read.
29
+     */
30
+    memset(&buffer[sizeof(buffer)-4], 0, 4);
31
     result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer);
32
     if (result) {
33
 	xmlGenericError(xmlGenericErrorContext, "%s", result);
34
-- 
35
GitLab
36
(-)b/textproc/libxml2/files/patch-CVE-2020-7595 (+32 lines)
Added Link Here
1
From 0e1a49c8907645d2e155f0d89d4d9895ac5112b5 Mon Sep 17 00:00:00 2001
2
From: Zhipeng Xie <xiezhipeng1@huawei.com>
3
Date: Thu, 12 Dec 2019 17:30:55 +0800
4
Subject: [PATCH] Fix infinite loop in xmlStringLenDecodeEntities
5
6
When ctxt->instate == XML_PARSER_EOF,xmlParseStringEntityRef
7
return NULL which cause a infinite loop in xmlStringLenDecodeEntities
8
9
Found with libFuzzer.
10
11
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
12
---
13
 parser.c | 3 ++-
14
 1 file changed, 2 insertions(+), 1 deletion(-)
15
16
diff --git a/parser.c b/parser.c
17
index d1c31963..a34bb6cd 100644
18
--- parser.c
19
+++ parser.c
20
@@ -2646,7 +2646,8 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
21
     else
22
         c = 0;
23
     while ((c != 0) && (c != end) && /* non input consuming loop */
24
-	   (c != end2) && (c != end3)) {
25
+           (c != end2) && (c != end3) &&
26
+           (ctxt->instate != XML_PARSER_EOF)) {
27
 
28
 	if (c == 0) break;
29
         if ((c == '&') && (str[1] == '#')) {
30
-- 
31
GitLab
32
(-)b/textproc/libxml2/files/patch-Python-39-support (-1 / +92 lines)
Added Link Here
0
- 
1
From edc7b6abb0c125eeb888748c334897f60aab0854 Mon Sep 17 00:00:00 2001
2
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
3
Date: Fri, 28 Feb 2020 12:48:14 +0100
4
Subject: [PATCH] Parenthesize Py<type>_Check() in ifs
5
6
In C, if expressions should be parenthesized.
7
PyLong_Check, PyUnicode_Check etc. happened to expand to a parenthesized
8
expression before, but that's not API to rely on.
9
10
Since Python 3.9.0a4 it needs to be parenthesized explicitly.
11
12
Fixes https://gitlab.gnome.org/GNOME/libxml2/issues/149
13
---
14
 python/libxml.c |  4 ++--
15
 python/types.c  | 12 ++++++------
16
 2 files changed, 8 insertions(+), 8 deletions(-)
17
18
diff --git a/python/libxml.c b/python/libxml.c
19
index bc676c4e..81e709f3 100644
20
--- python/libxml.c
21
+++ python/libxml.c
22
@@ -294,7 +294,7 @@ xmlPythonFileReadRaw (void * context, char * buffer, int len) {
23
 	lenread = PyBytes_Size(ret);
24
 	data = PyBytes_AsString(ret);
25
 #ifdef PyUnicode_Check
26
-    } else if PyUnicode_Check (ret) {
27
+    } else if (PyUnicode_Check (ret)) {
28
 #if PY_VERSION_HEX >= 0x03030000
29
         Py_ssize_t size;
30
 	const char *tmp;
31
@@ -359,7 +359,7 @@ xmlPythonFileRead (void * context, char * buffer, int len) {
32
 	lenread = PyBytes_Size(ret);
33
 	data = PyBytes_AsString(ret);
34
 #ifdef PyUnicode_Check
35
-    } else if PyUnicode_Check (ret) {
36
+    } else if (PyUnicode_Check (ret)) {
37
 #if PY_VERSION_HEX >= 0x03030000
38
         Py_ssize_t size;
39
 	const char *tmp;
40
diff --git a/python/types.c b/python/types.c
41
index c2bafeb1..ed284ec7 100644
42
--- python/types.c
43
+++ python/types.c
44
@@ -602,16 +602,16 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
45
     if (obj == NULL) {
46
         return (NULL);
47
     }
48
-    if PyFloat_Check (obj) {
49
+    if (PyFloat_Check (obj)) {
50
         ret = xmlXPathNewFloat((double) PyFloat_AS_DOUBLE(obj));
51
-    } else if PyLong_Check(obj) {
52
+    } else if (PyLong_Check(obj)) {
53
 #ifdef PyLong_AS_LONG
54
         ret = xmlXPathNewFloat((double) PyLong_AS_LONG(obj));
55
 #else
56
         ret = xmlXPathNewFloat((double) PyInt_AS_LONG(obj));
57
 #endif
58
 #ifdef PyBool_Check
59
-    } else if PyBool_Check (obj) {
60
+    } else if (PyBool_Check (obj)) {
61
 
62
         if (obj == Py_True) {
63
           ret = xmlXPathNewBoolean(1);
64
@@ -620,14 +620,14 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
65
           ret = xmlXPathNewBoolean(0);
66
         }
67
 #endif
68
-    } else if PyBytes_Check (obj) {
69
+    } else if (PyBytes_Check (obj)) {
70
         xmlChar *str;
71
 
72
         str = xmlStrndup((const xmlChar *) PyBytes_AS_STRING(obj),
73
                          PyBytes_GET_SIZE(obj));
74
         ret = xmlXPathWrapString(str);
75
 #ifdef PyUnicode_Check
76
-    } else if PyUnicode_Check (obj) {
77
+    } else if (PyUnicode_Check (obj)) {
78
 #if PY_VERSION_HEX >= 0x03030000
79
         xmlChar *str;
80
 	const char *tmp;
81
@@ -650,7 +650,7 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
82
 	ret = xmlXPathWrapString(str);
83
 #endif
84
 #endif
85
-    } else if PyList_Check (obj) {
86
+    } else if (PyList_Check (obj)) {
87
         int i;
88
         PyObject *node;
89
         xmlNodePtr cur;
90
-- 
91
GitLab
92

Return to bug 251040