aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2020-05-29 21:19:31 +0200
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:09:22 -0300
commite61a801ea2b55557140b82707a0c4a32d8411748 (patch)
tree981c62aa2e83aa86983085a5341a5943e18cc010 /gcc
parentca71dbbdc1022165ed858f9938f0606e0fc8a521 (diff)
downloadgcc-e61a801ea2b55557140b82707a0c4a32d8411748.zip
gcc-e61a801ea2b55557140b82707a0c4a32d8411748.tar.gz
gcc-e61a801ea2b55557140b82707a0c4a32d8411748.tar.bz2
PR fortran/95090 - ICE: identifier overflow
The initial fix for this PR uncovered several latent issues with further too small string buffers which showed up only when testing on i686. Provide sufficiently large temporaries. 2020-05-29 Harald Anlauf <anlauf@gmx.de> gcc/fortran/ PR fortran/95090 * class.c (get_unique_type_string): Enlarge temporary for name-mangling. Use strncpy to prevent buffer overrun. (get_unique_hashed_string): Enlarge temporary. (gfc_hash_value): Enlarge temporary for name-mangling.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/class.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index 9aa3eb7..db39562 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -479,11 +479,12 @@ gfc_class_initializer (gfc_typespec *ts, gfc_expr *init_expr)
static void
get_unique_type_string (char *string, gfc_symbol *derived)
{
- char dt_name[GFC_MAX_SYMBOL_LEN+1];
+ /* Provide sufficient space to hold "Pdtsymbol". */
+ char dt_name[GFC_MAX_SYMBOL_LEN+4];
if (derived->attr.unlimited_polymorphic)
strcpy (dt_name, "STAR");
else
- strcpy (dt_name, gfc_dt_upper_string (derived->name));
+ strncpy (dt_name, gfc_dt_upper_string (derived->name), sizeof (dt_name));
if (derived->attr.unlimited_polymorphic)
sprintf (string, "_%s", dt_name);
else if (derived->module)
@@ -501,7 +502,8 @@ get_unique_type_string (char *string, gfc_symbol *derived)
static void
get_unique_hashed_string (char *string, gfc_symbol *derived)
{
- char tmp[2*GFC_MAX_SYMBOL_LEN+2];
+ /* Provide sufficient space to hold "symbol_Pdtsymbol". */
+ char tmp[2*GFC_MAX_SYMBOL_LEN+5];
get_unique_type_string (&tmp[0], derived);
/* If string is too long, use hash value in hex representation (allow for
extra decoration, cf. gfc_build_class_symbol & gfc_find_derived_vtab).
@@ -523,7 +525,8 @@ unsigned int
gfc_hash_value (gfc_symbol *sym)
{
unsigned int hash = 0;
- char c[2*(GFC_MAX_SYMBOL_LEN+1)];
+ /* Provide sufficient space to hold "symbol_Pdtsymbol". */
+ char c[2*GFC_MAX_SYMBOL_LEN+5];
int i, len;
get_unique_type_string (&c[0], sym);