aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2020-05-30 20:50:59 +0200
committerHarald Anlauf <anlauf@gmx.de>2020-05-30 20:50:59 +0200
commitbf5fbbbd8c9a3385c1083cc80683bdb0195b1ffc (patch)
treeaf785d2b77191f9ee6f5b7ee3b7918a0fcc15e5f /gcc/fortran
parent9df0ff5f219b9e93d007f42939a6449ce2521cf5 (diff)
downloadgcc-bf5fbbbd8c9a3385c1083cc80683bdb0195b1ffc.zip
gcc-bf5fbbbd8c9a3385c1083cc80683bdb0195b1ffc.tar.gz
gcc-bf5fbbbd8c9a3385c1083cc80683bdb0195b1ffc.tar.bz2
PR fortran/95090 - ICE: identifier overflow
Implement buffer overrun check for temporary that holds mangled names. 2020-05-30 Harald Anlauf <anlauf@gmx.de> gcc/fortran/ PR fortran/95090 * class.c (get_unique_type_string): Use buffer overrun check.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/class.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index db395624a..afd8885 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)