From: Harald Anlauf Date: Sat, 30 May 2020 18:50:59 +0000 (+0200) Subject: PR fortran/95090 - ICE: identifier overflow X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bf5fbbbd8c9a3385c1083cc80683bdb0195b1ffc;p=gcc.git PR fortran/95090 - ICE: identifier overflow Implement buffer overrun check for temporary that holds mangled names. 2020-05-30 Harald Anlauf gcc/fortran/ PR fortran/95090 * class.c (get_unique_type_string): Use buffer overrun check. --- diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index db395624a16..afd8885a1ea 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -484,7 +484,14 @@ get_unique_type_string (char *string, gfc_symbol *derived) if (derived->attr.unlimited_polymorphic) strcpy (dt_name, "STAR"); else - strncpy (dt_name, gfc_dt_upper_string (derived->name), sizeof (dt_name)); + { + const char *upper = gfc_dt_upper_string (derived->name); + size_t len = strnlen (upper, sizeof (dt_name)); + if (len >= sizeof (dt_name)) + gfc_internal_error ("get_unique_type_string: identifier overflow"); + memcpy (dt_name, upper, len); + dt_name[len] = '\0'; + } if (derived->attr.unlimited_polymorphic) sprintf (string, "_%s", dt_name); else if (derived->module)