summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc
diff options
context:
space:
mode:
authorJuro Bystricky <juro.bystricky@intel.com>2017-08-04 15:40:54 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-08-13 09:27:38 +0100
commitb9b6ede7f8a191b82e8c8c711ad7425fa774c876 (patch)
treeed6c8118d07e493a18ce24aca76c249f69ea2f0c /meta/recipes-devtools/gcc
parent9952b38de4002da66da677380ac86283f852ad22 (diff)
downloadpoky-b9b6ede7f8a191b82e8c8c711ad7425fa774c876.tar.gz
gcc7: fix potential segmentation fault
Under some rare circumstances we may end up with GCC segmentation fault. This was observed with versions of sysmacros.h, which contain macros with embedded warning messages : When trying to actually display the warning, we may end up with a segmentation fault instead. The reason is the actual warning message gets parsed (the text is unquoted) and words in the message such as "not", "and" etc. are interpreted as operators CPP_NOT, CPP_AND. When the time comes to display the warning, the code uses wrong structure to access the "name" corresponding to the operators. [YOCTO #11738] (From OE-Core rev: 6f81fe4f3a1177c0049b26a070e43546bc6fe974) Signed-off-by: Juro Bystricky <juro.bystricky@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/gcc')
-rw-r--r--meta/recipes-devtools/gcc/gcc-7.1.inc1
-rw-r--r--meta/recipes-devtools/gcc/gcc-7.1/fix-segmentation-fault-precompiled-hdr.patch49
2 files changed, 50 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-7.1.inc b/meta/recipes-devtools/gcc/gcc-7.1.inc
index 3f1c06dafd..2d9ca82de9 100644
--- a/meta/recipes-devtools/gcc/gcc-7.1.inc
+++ b/meta/recipes-devtools/gcc/gcc-7.1.inc
@@ -75,6 +75,7 @@ SRC_URI = "\
75 file://0048-gcc-Enable-static-PIE.patch \ 75 file://0048-gcc-Enable-static-PIE.patch \
76 file://0049-libsanitizer-Use-stack_t-instead-of-struct-sigaltsta.patch \ 76 file://0049-libsanitizer-Use-stack_t-instead-of-struct-sigaltsta.patch \
77 file://0050-replace-struct-ucontext-with-ucontext_t.patch \ 77 file://0050-replace-struct-ucontext-with-ucontext_t.patch \
78 file://fix-segmentation-fault-precompiled-hdr.patch \
78 ${BACKPORTS} \ 79 ${BACKPORTS} \
79" 80"
80BACKPORTS = "\ 81BACKPORTS = "\
diff --git a/meta/recipes-devtools/gcc/gcc-7.1/fix-segmentation-fault-precompiled-hdr.patch b/meta/recipes-devtools/gcc/gcc-7.1/fix-segmentation-fault-precompiled-hdr.patch
new file mode 100644
index 0000000000..c0adef6f2f
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-7.1/fix-segmentation-fault-precompiled-hdr.patch
@@ -0,0 +1,49 @@
1
2Prevent a segmentation fault which occurs when using incorrect
3structure trying to access name of some named operators, such as
4CPP_NOT, CPP_AND etc. "token->val.node.spelling" cannot be used in
5those cases, as is may not be initialized at all.
6
7
8[YOCTO #11738]
9
10Upstream-Status: Pending
11
12Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
13
14diff --git a/libcpp/lex.c b/libcpp/lex.c
15--- a/libcpp/lex.c
16+++ b/libcpp/lex.c
17@@ -3229,11 +3229,27 @@
18 spell_ident:
19 case SPELL_IDENT:
20 if (forstring)
21- {
22- memcpy (buffer, NODE_NAME (token->val.node.spelling),
23- NODE_LEN (token->val.node.spelling));
24- buffer += NODE_LEN (token->val.node.spelling);
25- }
26+ {
27+ if (token->type == CPP_NAME)
28+ {
29+ memcpy (buffer, NODE_NAME (token->val.node.spelling),
30+ NODE_LEN (token->val.node.spelling));
31+ buffer += NODE_LEN (token->val.node.spelling);
32+ break;
33+ }
34+ /* NAMED_OP, cannot use node.spelling */
35+ if (token->flags & NAMED_OP)
36+ {
37+ const char *str = cpp_named_operator2name (token->type);
38+ if (str)
39+ {
40+ size_t len = strlen(str);
41+ memcpy(buffer, str, len);
42+ buffer += len;
43+ }
44+ break;
45+ }
46+ }
47 else
48 buffer = _cpp_spell_ident_ucns (buffer, token->val.node.node);
49 break;