diff options
author | Harald Anlauf <anlauf@gmx.de> | 2020-06-20 16:15:16 +0200 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-17 13:14:21 -0300 |
commit | 85421c7c712ea16c05f782348f62314c8709c2e9 (patch) | |
tree | 6708336e3158680f34ca88bf58ad95dbe1a5bead /gcc/fortran/trans-common.c | |
parent | af4a9ee8f1e29f3f3d304fa37f060956923ea0fe (diff) | |
download | gcc-85421c7c712ea16c05f782348f62314c8709c2e9.zip gcc-85421c7c712ea16c05f782348f62314c8709c2e9.tar.gz gcc-85421c7c712ea16c05f782348f62314c8709c2e9.tar.bz2 |
PR fortran/95707 - ICE in finish_equivalences, at fortran/trans-common.c:1319
With submodules and equivalence declarations, name mangling may result in
long internal symbols overflowing internal buffers. We now check that
we do not exceed the enlarged buffer sizes.
gcc/fortran/
PR fortran/95707
* gfortran.h (gfc_common_head): Enlarge buffer.
* trans-common.c (gfc_sym_mangled_common_id): Enlarge temporary
buffers, and add check on length on mangled name to prevent
overflow.
Diffstat (limited to 'gcc/fortran/trans-common.c')
-rw-r--r-- | gcc/fortran/trans-common.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c index 1acc336..c6383fc 100644 --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -242,11 +242,13 @@ static tree gfc_sym_mangled_common_id (gfc_common_head *com) { int has_underscore; - /* Provide sufficient space to hold "symbol.eq.1234567890__". */ - char mangled_name[GFC_MAX_MANGLED_SYMBOL_LEN + 1 + 16]; - char name[GFC_MAX_SYMBOL_LEN + 1 + 16]; + /* Provide sufficient space to hold "symbol.symbol.eq.1234567890__". */ + char mangled_name[2*GFC_MAX_MANGLED_SYMBOL_LEN + 1 + 16 + 1]; + char name[sizeof (mangled_name) - 2]; /* Get the name out of the common block pointer. */ + size_t len = strlen (com->name); + gcc_assert (len < sizeof (name)); strcpy (name, com->name); /* If we're suppose to do a bind(c). */ |