diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1993-01-18 06:23:11 -0500 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1993-01-18 06:23:11 -0500 |
commit | aee42e2745064c7be6d2dcd360a70e64910fe309 (patch) | |
tree | 4d0107eee2baff5ad715de629a8fa96832d2365a | |
parent | dd30a199df3a6d7cb56245989be379dcde9ab9e9 (diff) | |
download | gcc-aee42e2745064c7be6d2dcd360a70e64910fe309.zip gcc-aee42e2745064c7be6d2dcd360a70e64910fe309.tar.gz gcc-aee42e2745064c7be6d2dcd360a70e64910fe309.tar.bz2 |
(choose_temp_base, main): Fix "off by one" errors in sizes of
allocated strings.
From-SVN: r3261
-rw-r--r-- | gcc/collect2.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/gcc/collect2.c b/gcc/collect2.c index 50381d7..6730401 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -441,7 +441,7 @@ choose_temp_base () } len = strlen (base); - temp_filename = xmalloc (len + sizeof("/ccXXXXXX")); + temp_filename = xmalloc (len + sizeof("/ccXXXXXX") + 1); strcpy (temp_filename, base); if (len > 0 && temp_filename[len-1] != '/') temp_filename[len++] = '/'; @@ -699,43 +699,43 @@ main (argc, argv) qualify the program name with the target machine. */ full_ld_suffix - = xcalloc (strlen (ld_suffix) + strlen (target_machine) + 1, 1); + = xcalloc (strlen (ld_suffix) + strlen (target_machine) + 2, 1); strcpy (full_ld_suffix, ld_suffix); strcat (full_ld_suffix, "-"); strcat (full_ld_suffix, target_machine); full_real_ld_suffix - = xcalloc (strlen (real_ld_suffix) + strlen (target_machine) + 1, 1); + = xcalloc (strlen (real_ld_suffix) + strlen (target_machine) + 2, 1); strcpy (full_real_ld_suffix, real_ld_suffix); strcat (full_real_ld_suffix, "-"); strcat (full_real_ld_suffix, target_machine); full_gld_suffix - = xcalloc (strlen (gld_suffix) + strlen (target_machine) + 1, 1); + = xcalloc (strlen (gld_suffix) + strlen (target_machine) + 2, 1); strcpy (full_gld_suffix, gld_suffix); strcat (full_gld_suffix, "-"); strcat (full_gld_suffix, target_machine); full_nm_suffix - = xcalloc (strlen (nm_suffix) + strlen (target_machine) + 1, 1); + = xcalloc (strlen (nm_suffix) + strlen (target_machine) + 2, 1); strcpy (full_nm_suffix, nm_suffix); strcat (full_nm_suffix, "-"); strcat (full_nm_suffix, target_machine); full_gnm_suffix - = xcalloc (strlen (gnm_suffix) + strlen (target_machine) + 1, 1); + = xcalloc (strlen (gnm_suffix) + strlen (target_machine) + 2, 1); strcpy (full_gnm_suffix, gnm_suffix); strcat (full_gnm_suffix, "-"); strcat (full_gnm_suffix, target_machine); full_strip_suffix - = xcalloc (strlen (strip_suffix) + strlen (target_machine) + 1, 1); + = xcalloc (strlen (strip_suffix) + strlen (target_machine) + 2, 1); strcpy (full_strip_suffix, strip_suffix); strcat (full_strip_suffix, "-"); strcat (full_strip_suffix, target_machine); full_gstrip_suffix - = xcalloc (strlen (gstrip_suffix) + strlen (target_machine) + 1, 1); + = xcalloc (strlen (gstrip_suffix) + strlen (target_machine) + 2, 1); strcpy (full_gstrip_suffix, gstrip_suffix); strcat (full_gstrip_suffix, "-"); strcat (full_gstrip_suffix, target_machine); @@ -796,7 +796,7 @@ main (argc, argv) if (c_file_name == 0) { #ifdef CROSS_COMPILE - c_file_name = xcalloc (strlen ("gcc") + strlen (target_machine) + 1, 1); + c_file_name = xcalloc (sizeof ("gcc-") + strlen (target_machine) + 1, 1); strcpy (c_file_name, "gcc-"); strcat (c_file_name, target_machine); #else |