diff options
author | Martin Liska <mliska@suse.cz> | 2016-08-15 13:16:50 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2016-08-15 11:16:50 +0000 |
commit | 38359141158751b6f35fd4b282b07a717cfa3e19 (patch) | |
tree | cd84f67a0409e446e625333e54361fafc91bd35d /gcc | |
parent | 397d8acd712325e0885f092e01f69bcade62adbd (diff) | |
download | gcc-38359141158751b6f35fd4b282b07a717cfa3e19.zip gcc-38359141158751b6f35fd4b282b07a717cfa3e19.tar.gz gcc-38359141158751b6f35fd4b282b07a717cfa3e19.tar.bz2 |
Fix invalid memory access in gcc.c (driver/72765)
PR driver/72765
* gcc.c (do_spec_1): Call save_string with the right size.
(save_string): Do an assert about string we copy.
From-SVN: r239475
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/gcc.c | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2b5355d..dc7e8cb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-08-15 Martin Liska <mliska@suse.cz> + + PR driver/72765 + * gcc.c (do_spec_1): Call save_string with the right size. + (save_string): Do an assert about string we copy. + 2016-08-15 Richard Biener <rguenther@suse.de> * ree.c (rest_of_handle_ree): Remove redundant timevar push/pop. @@ -5420,8 +5420,9 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) if (files_differ) #endif { - temp_filename = save_string (temp_filename, - temp_filename_length + 1); + temp_filename + = save_string (temp_filename, + temp_filename_length - 1); obstack_grow (&obstack, temp_filename, temp_filename_length); arg_going = 1; @@ -8362,6 +8363,7 @@ save_string (const char *s, int len) { char *result = XNEWVEC (char, len + 1); + gcc_checking_assert (strlen (s) >= (unsigned int) len); memcpy (result, s, len); result[len] = 0; return result; |