This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] gcc/c/c-aux-info.c: Resize 'buff' from 10 to 14 bytes


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]