public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] gcc/gcc.c: XNEWVEC enough space for 'saved_suffix' using
@ 2014-07-24 15:32 Chen Gang
  2014-07-30 22:20 ` Joseph S. Myers
  2014-07-31 22:48 ` Jeff Law
  0 siblings, 2 replies; 27+ messages in thread
From: Chen Gang @ 2014-07-24 15:32 UTC (permalink / raw)
  To: Jeff Law, Joseph S. Myers, rth; +Cc: gcc-patches

strlen() will get string length excluding '\0', but strcpy() will append
'\0' in the end, so need XNEWVEC additional byte, or cause memory over
flow.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 gcc/gcc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/gcc.c b/gcc/gcc.c
index 6cd08ea..8ea46ec 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -4895,7 +4895,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
 		      {
 			saved_suffix
 			  = XNEWVEC (char, suffix_length
-				     + strlen (TARGET_OBJECT_SUFFIX));
+				     + strlen (TARGET_OBJECT_SUFFIX) + 1);
 			strncpy (saved_suffix, suffix, suffix_length);
 			strcpy (saved_suffix + suffix_length,
 				TARGET_OBJECT_SUFFIX);
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2014-08-21 21:31 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-24 15:32 [PATCH] gcc/gcc.c: XNEWVEC enough space for 'saved_suffix' using Chen Gang
2014-07-30 22:20 ` Joseph S. Myers
2014-07-30 22:29   ` Chen Gang
2014-07-30 23:19     ` Joseph S. Myers
2014-07-31  2:13       ` Chen Gang
2014-07-31  3:17       ` Jeff Law
2014-07-31  4:48         ` Chen Gang
2014-07-31 22:48 ` Jeff Law
2014-08-01  1:38   ` Chen Gang
2014-08-01  2:14     ` Mike Stump
2014-08-01  2:18       ` Chen Gang
2014-08-09 16:51   ` Chen Gang
2014-08-09 22:48     ` Chen Gang
2014-08-10  8:04     ` Mike Stump
2014-08-10  8:15       ` Chen Gang
2014-08-17 10:48         ` Chen Gang
2014-08-18  7:05           ` Bin.Cheng
2014-08-18 10:01             ` Chen Gang
2014-08-18 10:07               ` Bin.Cheng
2014-08-18 10:12                 ` Chen Gang
2014-08-20 14:26                   ` Chen Gang
2014-08-20 17:36                     ` Mike Stump
2014-08-20 18:29                       ` Chen Gang
2014-08-20 19:23                         ` Mike Stump
2014-08-20 22:08                           ` Chen Gang
2014-08-21 16:18               ` Mike Stump
2014-08-21 21:31                 ` Chen Gang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).