From: Richard Kenner Date: Mon, 18 Jan 1993 11:23:11 +0000 (-0500) Subject: (choose_temp_base, main): Fix "off by one" errors in sizes of X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aee42e2745064c7be6d2dcd360a70e64910fe309;p=gcc.git (choose_temp_base, main): Fix "off by one" errors in sizes of allocated strings. From-SVN: r3261 --- diff --git a/gcc/collect2.c b/gcc/collect2.c index 50381d7951b..67304010cd9 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