[Bug fortran/95530] [11 regression] ICE in gfortran.dg/equiv_11.f90 after r11-594
anlauf at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jun 4 21:06:45 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95530
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |anlauf at gcc dot gnu.org
--- Comment #6 from anlauf at gcc dot gnu.org ---
In addition to the patch in comment#5, we can "harden" the strcpy:
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index 3775a8bea74..1acc336eacf 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -1314,7 +1314,11 @@ finish_equivalences (gfc_namespace *ns)
c->where = ns->proc_name->declared_at;
else if (ns->is_block_data)
c->where = ns->sym_root->n.sym->declared_at;
- strcpy (c->name, z->module);
+
+ size_t len = strlen (z->module);
+ gcc_assert (len < sizeof (c->name));
+ memcpy (c->name, z->module, len);
+ c->name[len] = '\0';
}
else
c = NULL;
More information about the Gcc-bugs
mailing list