This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] gcc/c-family/c-cppbuiltin.c: Add two bytes for avoiding memory overflow issue
- From: Chen Gang <gang dot chen dot 5i5j at gmail dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>, rth at redhat dot com, Jeff Law <law at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 16 Nov 2014 22:32:34 +0800
- Subject: [PATCH] gcc/c-family/c-cppbuiltin.c: Add two bytes for avoiding memory overflow issue
- Authentication-results: sourceware.org; auth=none
When 'is_str' is true, need consider about 2 '"' for the extra space, or
will cause memory overflow.
2014-11-16 Chen Gang <gang.chen.5i5j@gmail.com>
* c-family/c-cppbuiltin.c (builtin_define_with_value): Add two
bytes for avoiding memory overflow issue.
---
gcc/c-family/c-cppbuiltin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 8e8cec4..cc3d90b 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -1282,7 +1282,7 @@ builtin_define_with_value (const char *macro, const char *expansion, int is_str)
char *buf;
size_t mlen = strlen (macro);
size_t elen = strlen (expansion);
- size_t extra = 2; /* space for an = and a NUL */
+ size_t extra = 4; /* space for an =, a NUL, and 2 '"' when is_str is true */
if (is_str)
{
--
1.9.3