* [PATCH] PR fortran/95827 - Buffer overflows with PDTs and long symbols
@ 2020-06-23 21:08 Harald Anlauf
2020-06-23 21:42 ` Jerry DeLisle
2020-06-24 17:09 ` Thomas Koenig
0 siblings, 2 replies; 3+ messages in thread
From: Harald Anlauf @ 2020-06-23 21:08 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 439 bytes --]
Dear all,
here's another case with a buffer that did overflow.
Regtested on x86_64-pc-linux-gnu.
OK for master / backports?
Thanks,
Harald
PR fortran/95827 - Buffer overflows with PDTs and long symbols
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr95827.patch --]
[-- Type: text/x-patch, Size: 1449 bytes --]
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] 3+ messages in thread
* Re: [PATCH] PR fortran/95827 - Buffer overflows with PDTs and long symbols
2020-06-23 21:08 [PATCH] PR fortran/95827 - Buffer overflows with PDTs and long symbols Harald Anlauf
@ 2020-06-23 21:42 ` Jerry DeLisle
2020-06-24 17:09 ` Thomas Koenig
1 sibling, 0 replies; 3+ messages in thread
From: Jerry DeLisle @ 2020-06-23 21:42 UTC (permalink / raw)
To: Harald Anlauf, fortran, gcc-patches
OK, and thanks for Patch.
On 6/23/20 2:08 PM, Harald Anlauf wrote:
> Dear all,
>
> here's another case with a buffer that did overflow.
>
> Regtested on x86_64-pc-linux-gnu.
>
> OK for master / backports?
>
> Thanks,
> Harald
>
>
> PR fortran/95827 - Buffer overflows with PDTs and long symbols
>
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PR fortran/95827 - Buffer overflows with PDTs and long symbols
2020-06-23 21:08 [PATCH] PR fortran/95827 - Buffer overflows with PDTs and long symbols Harald Anlauf
2020-06-23 21:42 ` Jerry DeLisle
@ 2020-06-24 17:09 ` Thomas Koenig
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Koenig @ 2020-06-24 17:09 UTC (permalink / raw)
To: Harald Anlauf, fortran, gcc-patches
Hi Haraldd,
> here's another case with a buffer that did overflow.
>
> Regtested on x86_64-pc-linux-gnu.
>
> OK for master / backports?
OK. Thanks for the patch!
Best regards
Thomas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-24 17:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 21:08 [PATCH] PR fortran/95827 - Buffer overflows with PDTs and long symbols Harald Anlauf
2020-06-23 21:42 ` Jerry DeLisle
2020-06-24 17:09 ` Thomas Koenig
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).