public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: off-by-one buffer overflow patch
@ 2021-03-26 17:38 dhumieres.dominique
  2021-03-27  5:36 ` Jerry DeLisle
  0 siblings, 1 reply; 6+ messages in thread
From: dhumieres.dominique @ 2021-03-26 17:38 UTC (permalink / raw)
  To: sgk; +Cc: fortran

I have proposed a similar patch in pr95998.

I cannot commit to git!-(

Thanks

Dominique

^ permalink raw reply	[flat|nested] 6+ messages in thread
* off-by-one buffer overflow patch
@ 2021-03-26 17:29 Steve Kargl
  0 siblings, 0 replies; 6+ messages in thread
From: Steve Kargl @ 2021-03-26 17:29 UTC (permalink / raw)
  To: fortran, gcc-patches

This patch fixes an off-by-one buffer overflow issue.
Please commit.


diff --git a/gcc/fortran/misc.c b/gcc/fortran/misc.c
index 8a96243e80d..3d449ae17fe 100644
--- a/gcc/fortran/misc.c
+++ b/gcc/fortran/misc.c
@@ -124,8 +124,10 @@ gfc_basic_typename (bt type)
 const char *
 gfc_typename (gfc_typespec *ts, bool for_hash)
 {
-  static char buffer1[GFC_MAX_SYMBOL_LEN + 7];  /* 7 for "TYPE()" + '\0'.  */
-  static char buffer2[GFC_MAX_SYMBOL_LEN + 7];
+  /* Need to add sufficient padding for "TYPE()" + '\0', "UNION()" + '\0',
+     or "CLASS()" + '\0'.  */
+  static char buffer1[GFC_MAX_SYMBOL_LEN + 8];
+  static char buffer2[GFC_MAX_SYMBOL_LEN + 8];
   static int flag = 0;
   char *buffer;
   gfc_typespec *ts1;

-- 
Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-27 23:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 17:38 off-by-one buffer overflow patch dhumieres.dominique
2021-03-27  5:36 ` Jerry DeLisle
2021-03-27 13:28   ` dhumieres.dominique
2021-03-27 22:11     ` Jerry DeLisle
2021-03-27 23:49       ` Steve Kargl
  -- strict thread matches above, loose matches on Subject: below --
2021-03-26 17:29 Steve Kargl

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