summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/expat/expat/CVE-2021-46143.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/expat/expat/CVE-2021-46143.patch')
-rw-r--r--meta/recipes-core/expat/expat/CVE-2021-46143.patch43
1 files changed, 43 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)