summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Sakoman <steve@sakoman.com>2022-01-19 04:59:07 -1000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-01-25 12:06:55 +0000
commit8c58e222ea496d73cba1dd1e12600f980b6007af (patch)
treed356e4b7053994162e4b67b4b59b19d2bdaa8aa0
parentb618e57f798148c3d032129cf1e60fd209730dfd (diff)
downloadpoky-8c58e222ea496d73cba1dd1e12600f980b6007af.tar.gz
expat: fix CVE-2021-46143
In doProlog in xmlparse.c in Expat (aka libexpat) before 2.4.3, an integer overflow exists for m_groupSize. Backport patch from: https://github.com/libexpat/libexpat/pull/538/commits/85ae9a2d7d0e9358f356b33977b842df8ebaec2b CVE: CVE-2021-46143 (From OE-Core rev: 41a65d27e4ecdc11977e2944d8af2f51c48f32ec) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/expat/expat/CVE-2021-46143.patch43
-rw-r--r--meta/recipes-core/expat/expat_2.2.9.bb1
2 files changed, 44 insertions, 0 deletions
diff --git a/meta/recipes-core/expat/expat/CVE-2021-46143.patch b/meta/recipes-core/expat/expat/CVE-2021-46143.patch
new file mode 100644
index 0000000000..d6bafba0ff
--- /dev/null
+++ b/meta/recipes-core/expat/expat/CVE-2021-46143.patch
@@ -0,0 +1,43 @@
1From 85ae9a2d7d0e9358f356b33977b842df8ebaec2b Mon Sep 17 00:00:00 2001
2From: Sebastian Pipping <sebastian@pipping.org>
3Date: Sat, 25 Dec 2021 20:52:08 +0100
4Subject: [PATCH] lib: Prevent integer overflow on m_groupSize in function
5 doProlog (CVE-2021-46143)
6
7---
8 expat/lib/xmlparse.c | 15 +++++++++++++++
9 1 file changed, 15 insertions(+)
10
11diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c
12index b47c31b0..8f243126 100644
13--- a/lib/xmlparse.c
14+++ b/lib/xmlparse.c
15@@ -5046,6 +5046,11 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
16 if (parser->m_prologState.level >= parser->m_groupSize) {
17 if (parser->m_groupSize) {
18 {
19+ /* Detect and prevent integer overflow */
20+ if (parser->m_groupSize > (unsigned int)(-1) / 2u) {
21+ return XML_ERROR_NO_MEMORY;
22+ }
23+
24 char *const new_connector = (char *)REALLOC(
25 parser, parser->m_groupConnector, parser->m_groupSize *= 2);
26 if (new_connector == NULL) {
27@@ -5056,6 +5061,16 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
28 }
29
30 if (dtd->scaffIndex) {
31+ /* Detect and prevent integer overflow.
32+ * The preprocessor guard addresses the "always false" warning
33+ * from -Wtype-limits on platforms where
34+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
35+#if UINT_MAX >= SIZE_MAX
36+ if (parser->m_groupSize > (size_t)(-1) / sizeof(int)) {
37+ return XML_ERROR_NO_MEMORY;
38+ }
39+#endif
40+
41 int *const new_scaff_index = (int *)REALLOC(
42 parser, dtd->scaffIndex, parser->m_groupSize * sizeof(int));
43 if (new_scaff_index == NULL)
diff --git a/meta/recipes-core/expat/expat_2.2.9.bb b/meta/recipes-core/expat/expat_2.2.9.bb
index a21e59f987..757c18c5fa 100644
--- a/meta/recipes-core/expat/expat_2.2.9.bb
+++ b/meta/recipes-core/expat/expat_2.2.9.bb
@@ -9,6 +9,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=5b8620d98e49772d95fc1d291c26aa79"
9SRC_URI = "git://github.com/libexpat/libexpat.git;protocol=https;branch=master \ 9SRC_URI = "git://github.com/libexpat/libexpat.git;protocol=https;branch=master \
10 file://CVE-2013-0340.patch \ 10 file://CVE-2013-0340.patch \
11 file://CVE-2021-45960.patch \ 11 file://CVE-2021-45960.patch \
12 file://CVE-2021-46143.patch \
12 file://CVE-2022-22822-27.patch \ 13 file://CVE-2022-22822-27.patch \
13 file://libtool-tag.patch \ 14 file://libtool-tag.patch \
14 " 15 "