public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/redhat/heads/gcc-8-branch)] PR fortran/95689 - ICE in check_sym_interfaces, at fortran/interface.c:2015 Date: Thu, 17 Sep 2020 17:08:15 +0000 (GMT) [thread overview] Message-ID: <20200917170815.BC42F398B89A@sourceware.org> (raw) https://gcc.gnu.org/g:7bac7d19449c1d0e1bde97534ac43627e28526a5 commit 7bac7d19449c1d0e1bde97534ac43627e28526a5 Author: Harald Anlauf <anlauf@gmx.de> Date: Sat Jun 20 16:09:45 2020 +0200 PR fortran/95689 - ICE in check_sym_interfaces, at fortran/interface.c:2015 With submodules, name mangling of interfaces may result in long internal symbols overflowing an internal buffer. We now check that we do not exceed the enlarged buffer size. gcc/fortran/ PR fortran/95689 * interface.c (check_sym_interfaces): Enlarge temporary buffer, and add check on length on mangled name to prevent overflow. (cherry picked from commit 62c0c0ea7bfb6f8f6b8d767b05120cafb6823da6) Diff: --- gcc/fortran/interface.c | 5 ++++- gcc/testsuite/gfortran.dg/pr95689.f90 | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 689c30210d7..ec8fd3a8f68 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1944,7 +1944,8 @@ check_interface1 (gfc_interface *p, gfc_interface *q0, static void check_sym_interfaces (gfc_symbol *sym) { - char interface_name[GFC_MAX_SYMBOL_LEN + sizeof("generic interface ''")]; + /* Provide sufficient space to hold "generic interface 'symbol.symbol'". */ + char interface_name[2*GFC_MAX_SYMBOL_LEN+2 + sizeof("generic interface ''")]; gfc_interface *p; if (sym->ns != gfc_current_ns) @@ -1952,6 +1953,8 @@ check_sym_interfaces (gfc_symbol *sym) if (sym->generic != NULL) { + size_t len = strlen (sym->name) + sizeof("generic interface ''"); + gcc_assert (len < sizeof (interface_name)); sprintf (interface_name, "generic interface '%s'", sym->name); if (check_interface0 (sym->generic, interface_name)) return; diff --git a/gcc/testsuite/gfortran.dg/pr95689.f90 b/gcc/testsuite/gfortran.dg/pr95689.f90 new file mode 100644 index 00000000000..287ae50b0cb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr95689.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! { dg-options "-fsecond-underscore" } +! PR fortran/95689 - ICE in check_sym_interfaces, at fortran/interface.c:2015 + +module m2345678901234567890123456789012345678901234567890123456789_123 + type t2345678901234567890123456789012345678901234567890123456789_123 + end type + interface + module subroutine s2345678901234567890123456789012345678901234567890123456789_123 & + (x2345678901234567890123456789012345678901234567890123456789_123) + end + end interface +end +submodule(m2345678901234567890123456789012345678901234567890123456789_123) & + t2345678901234567890123456789012345678901234567890123456789_123 +end
reply other threads:[~2020-09-17 17:08 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200917170815.BC42F398B89A@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).