summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core')
-rw-r--r--meta/recipes-core/musl/files/CVE-2016-8859.patch79
-rw-r--r--meta/recipes-core/musl/musl_git.bb3
2 files changed, 1 insertions, 81 deletions
diff --git a/meta/recipes-core/musl/files/CVE-2016-8859.patch b/meta/recipes-core/musl/files/CVE-2016-8859.patch
deleted file mode 100644
index 82da86f0bd..0000000000
--- a/meta/recipes-core/musl/files/CVE-2016-8859.patch
+++ /dev/null
@@ -1,79 +0,0 @@
1From c3edc06d1e1360f3570db9155d6b318ae0d0f0f7 Mon Sep 17 00:00:00 2001
2From: Rich Felker <dalias@aerifal.cx>
3Date: Thu, 6 Oct 2016 18:34:58 -0400
4Subject: [PATCH] fix missing integer overflow checks in regexec buffer size
5 computations
6
7most of the possible overflows were already ruled out in practice by
8regcomp having already succeeded performing larger allocations.
9however at least the num_states*num_tags multiplication can clearly
10overflow in practice. for safety, check them all, and use the proper
11type, size_t, rather than int.
12
13also improve comments, use calloc in place of malloc+memset, and
14remove bogus casts.
15
16Upstream-Status: Backport
17CVE: CVE-2016-8859
18
19Signed-off-by: Armin Kuster <akuster@mvista.com>
20
21---
22 src/regex/regexec.c | 23 ++++++++++++++++++-----
23 1 file changed, 18 insertions(+), 5 deletions(-)
24
25diff --git a/src/regex/regexec.c b/src/regex/regexec.c
26index 16c5d0a..dd52319 100644
27--- a/src/regex/regexec.c
28+++ b/src/regex/regexec.c
29@@ -34,6 +34,7 @@
30 #include <wchar.h>
31 #include <wctype.h>
32 #include <limits.h>
33+#include <stdint.h>
34
35 #include <regex.h>
36
37@@ -206,11 +207,24 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
38
39 /* Allocate memory for temporary data required for matching. This needs to
40 be done for every matching operation to be thread safe. This allocates
41- everything in a single large block from the stack frame using alloca()
42- or with malloc() if alloca is unavailable. */
43+ everything in a single large block with calloc(). */
44 {
45- int tbytes, rbytes, pbytes, xbytes, total_bytes;
46+ size_t tbytes, rbytes, pbytes, xbytes, total_bytes;
47 char *tmp_buf;
48+
49+ /* Ensure that tbytes and xbytes*num_states cannot overflow, and that
50+ * they don't contribute more than 1/8 of SIZE_MAX to total_bytes. */
51+ if (num_tags > SIZE_MAX/(8 * sizeof(int) * tnfa->num_states))
52+ goto error_exit;
53+
54+ /* Likewise check rbytes. */
55+ if (tnfa->num_states+1 > SIZE_MAX/(8 * sizeof(*reach_next)))
56+ goto error_exit;
57+
58+ /* Likewise check pbytes. */
59+ if (tnfa->num_states > SIZE_MAX/(8 * sizeof(*reach_pos)))
60+ goto error_exit;
61+
62 /* Compute the length of the block we need. */
63 tbytes = sizeof(*tmp_tags) * num_tags;
64 rbytes = sizeof(*reach_next) * (tnfa->num_states + 1);
65@@ -221,10 +235,9 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
66 + (rbytes + xbytes * tnfa->num_states) * 2 + tbytes + pbytes;
67
68 /* Allocate the memory. */
69- buf = xmalloc((unsigned)total_bytes);
70+ buf = calloc(total_bytes, 1);
71 if (buf == NULL)
72 return REG_ESPACE;
73- memset(buf, 0, (size_t)total_bytes);
74
75 /* Get the various pointers within tmp_buf (properly aligned). */
76 tmp_tags = (void *)buf;
77--
782.7.4
79
diff --git a/meta/recipes-core/musl/musl_git.bb b/meta/recipes-core/musl/musl_git.bb
index 1ee56b6434..b0c6098133 100644
--- a/meta/recipes-core/musl/musl_git.bb
+++ b/meta/recipes-core/musl/musl_git.bb
@@ -3,7 +3,7 @@
3 3
4require musl.inc 4require musl.inc
5 5
6SRCREV = "39494a273eaa6b714e0fa0c59ce7a1f5fbc80a1e" 6SRCREV = "54991729fd1e3d3a0cb71884d758d86afe6da9e0"
7 7
8PV = "1.1.15+git${SRCPV}" 8PV = "1.1.15+git${SRCPV}"
9 9
@@ -11,7 +11,6 @@ PV = "1.1.15+git${SRCPV}"
11 11
12SRC_URI = "git://git.musl-libc.org/musl \ 12SRC_URI = "git://git.musl-libc.org/musl \
13 file://0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch \ 13 file://0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch \
14 file://CVE-2016-8859.patch \
15 " 14 "
16 15
17S = "${WORKDIR}/git" 16S = "${WORKDIR}/git"