Commit b3c17dfe by Harald Anlauf

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.

(cherry picked from commit bf5fbbbd8c9a3385c1083cc80683bdb0195b1ffc)
parent 78c4b06a
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment