diff options
author | Harald Anlauf <anlauf@gmx.de> | 2020-06-14 16:12:47 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2020-06-14 16:12:47 +0200 |
commit | 3ee9d82484bdc0ae5b1b21f4a3d8ff46d40e36fd (patch) | |
tree | e2f261c3bf5b56b7bb5006b6d86a83720f37bdf6 /gcc/fortran | |
parent | 4644e8f15f835a9934a8d289ee08ba4cb46cbfac (diff) | |
download | gcc-3ee9d82484bdc0ae5b1b21f4a3d8ff46d40e36fd.zip gcc-3ee9d82484bdc0ae5b1b21f4a3d8ff46d40e36fd.tar.gz gcc-3ee9d82484bdc0ae5b1b21f4a3d8ff46d40e36fd.tar.bz2 |
PR fortran/95088 - Buffer overflows with PDTs, submodules and long symbols
With PDTs (parameterized derived types) and submodules, name mangling
results in variably long internal symbols. Instead of using a fixed-size
intermediate buffer, which is actually not really needed, just use a
pointer to strings.
2020-06-14 Harald Anlauf <anlauf@gmx.de>
gcc/fortran/
PR fortran/95088
* class.c (get_unique_type_string): Replace use of fixed size
buffer by internally passing a pointer to strings.
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/class.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index cfc4502..227134e 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -479,19 +479,11 @@ gfc_class_initializer (gfc_typespec *ts, gfc_expr *init_expr) static void get_unique_type_string (char *string, gfc_symbol *derived) { - /* Provide sufficient space to hold "Pdtsymbol". */ - char dt_name[GFC_MAX_SYMBOL_LEN+4]; + const char *dt_name; if (derived->attr.unlimited_polymorphic) - strcpy (dt_name, "STAR"); + dt_name = "STAR"; else - { - 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'; - } + dt_name = gfc_dt_upper_string (derived->name); if (derived->attr.unlimited_polymorphic) sprintf (string, "_%s", dt_name); else if (derived->module) |