public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aldyh/heads/ranger-staging)] PR fortran/95827 - Buffer overflows with submodules and coarrays
@ 2020-06-27 21:28 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2020-06-27 21:28 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a16d0924f18046704ef9a4b6d9593718594677f1

commit a16d0924f18046704ef9a4b6d9593718594677f1
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Jun 24 21:03:47 2020 +0200

    PR fortran/95827 - Buffer overflows with submodules and coarrays
    
    With submodules and coarrays, name mangling results in long internal
    symbols.  Enlarge internal buffer.
    
    gcc/fortran/
            PR fortran/95827
            * iresolve.c (gfc_get_string): Enlarge internal buffer used in
            generating the mangled name.

Diff:
---
 gcc/fortran/iresolve.c                |  4 ++--
 gcc/testsuite/gfortran.dg/pr95827.f90 | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index aa9bb328a0f..73769615c20 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -47,8 +47,8 @@ along with GCC; see the file COPYING3.  If not see
 const char *
 gfc_get_string (const char *format, ...)
 {
-  /* Provide sufficient space to hold "_F.symbol.symbol_MOD_symbol".  */
-  char temp_name[4 + 2*GFC_MAX_SYMBOL_LEN + 5 + GFC_MAX_SYMBOL_LEN + 1];
+  /* Provide sufficient space for "_F.caf_token__symbol.symbol_MOD_symbol".  */
+  char temp_name[15 + 2*GFC_MAX_SYMBOL_LEN + 5 + GFC_MAX_SYMBOL_LEN + 1];
   const char *str;
   va_list ap;
   tree ident;
diff --git a/gcc/testsuite/gfortran.dg/pr95827.f90 b/gcc/testsuite/gfortran.dg/pr95827.f90
new file mode 100644
index 00000000000..545e344c46d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95827.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib -fsecond-underscore" }
+! PR fortran/95827 - ICE in gfc_get_string, at fortran/iresolve.c:70
+
+module m2345678901234567890123456789012345678901234567890123456789_123
+  interface
+     module subroutine s2345678901234567890123456789012345678901234567890123456789_123
+     end
+   end interface
+end
+submodule(m2345678901234567890123456789012345678901234567890123456789_123) &
+          n2345678901234567890123456789012345678901234567890123456789_123
+  integer :: x2345678901234567890123456789012345678901234567890123456789_123[*]
+end


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-27 21:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-27 21:28 [gcc(refs/users/aldyh/heads/ranger-staging)] PR fortran/95827 - Buffer overflows with submodules and coarrays Aldy Hernandez

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).