This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] gcc/c/c-aux-info.c: Resize 'buff' from 10 to 14 bytes
- From: Chen Gang <gang dot chen dot 5i5j at gmail dot com>
- To: Jeff Law <law at redhat dot com>, Mike Stump <mrs at mrs dot kithrup dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, rth at redhat dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 10 Aug 2014 06:58:33 +0800
- Subject: [PATCH] gcc/c/c-aux-info.c: Resize 'buff' from 10 to 14 bytes
- Authentication-results: sourceware.org; auth=none
For "[%d]" in sprintf(), theoretically, the maximize size is 14 -- for
0x80000000, it is sizeof("[-2147483648]"). Normally, it may not cause
real world bug, but if another issues occur, it may lead things worse.
It passes "make && make check" under x86_64-apple-darwin13.3.0.
2014-08-09 Chen Gang <gang.chen.5i5j@gmail.com>
* c/c-aux-info.c (gen_type): Resize 'buff' from 10 to 14 bytes.
---
gcc/c/c-aux-info.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/c/c-aux-info.c b/gcc/c/c-aux-info.c
index 4b6b2d0..b7eacd7 100644
--- a/gcc/c/c-aux-info.c
+++ b/gcc/c/c-aux-info.c
@@ -311,7 +311,7 @@ gen_type (const char *ret_val, tree t, formals_style style)
else
{
int size = (int_size_in_bytes (t) / int_size_in_bytes (TREE_TYPE (t)));
- char buff[10];
+ char buff[14];
sprintf (buff, "[%d]", size);
ret_val = gen_type (concat (ret_val, buff, NULL),
TREE_TYPE (t), style);
--
1.8.5.2 (Apple Git-48)