diff options
author | Steve Sakoman <steve@sakoman.com> | 2022-01-19 04:59:07 -1000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-01-31 21:56:01 +0000 |
commit | ae9b6db2a14d5a174add8023ac836ed3ae737625 (patch) | |
tree | 1b70923fc5572c4539554e1da3afb79310106f5f /meta | |
parent | b769089b44b19dbc73c304c88b2ed67a4e03d844 (diff) | |
download | poky-ae9b6db2a14d5a174add8023ac836ed3ae737625.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: babe185972eb71058762ca20c349ba2651d0f73d)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
(cherry picked from commit 41a65d27e4ecdc11977e2944d8af2f51c48f32ec)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-core/expat/expat/CVE-2021-46143.patch | 43 | ||||
-rw-r--r-- | meta/recipes-core/expat/expat_2.2.10.bb | 1 |
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 @@ | |||
1 | From 85ae9a2d7d0e9358f356b33977b842df8ebaec2b Mon Sep 17 00:00:00 2001 | ||
2 | From: Sebastian Pipping <sebastian@pipping.org> | ||
3 | Date: Sat, 25 Dec 2021 20:52:08 +0100 | ||
4 | Subject: [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 | |||
11 | diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c | ||
12 | index 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.10.bb b/meta/recipes-core/expat/expat_2.2.10.bb index 7a892b0304..e5415361d8 100644 --- a/meta/recipes-core/expat/expat_2.2.10.bb +++ b/meta/recipes-core/expat/expat_2.2.10.bb | |||
@@ -14,6 +14,7 @@ SRC_URI = "https://github.com/libexpat/libexpat/releases/download/R_${VERSION_TA | |||
14 | file://0001-Add-output-of-tests-result.patch \ | 14 | file://0001-Add-output-of-tests-result.patch \ |
15 | file://CVE-2022-22822-27.patch \ | 15 | file://CVE-2022-22822-27.patch \ |
16 | file://CVE-2021-45960.patch \ | 16 | file://CVE-2021-45960.patch \ |
17 | file://CVE-2021-46143.patch \ | ||
17 | " | 18 | " |
18 | 19 | ||
19 | UPSTREAM_CHECK_URI = "https://github.com/libexpat/libexpat/releases/" | 20 | UPSTREAM_CHECK_URI = "https://github.com/libexpat/libexpat/releases/" |