This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] PR 19182


On Saturday 08 January 2005 00:04, Tobias Schlüter wrote:
> 2005-01-08  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
>
>  PR fortran/19182
>  * error.c (error_char): Line-buffer errors / warnings.

I fixed the potential buffer overflow, and applied as attached.

Paul
Index: error.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/fortran/error.c,v
retrieving revision 1.9
diff -u -p -r1.9 error.c
--- error.c	3 Jan 2005 21:43:49 -0000	1.9
+++ error.c	16 Jan 2005 17:17:14 -0000
@@ -86,7 +86,20 @@ error_char (char c)
   else
     {
       if (c != 0)
-	fputc (c, stderr);
+	{
+	  /* We build up complete lines before handing things
+	     over to the library in order to speed up error printing.  */
+	  static char line[MAX_ERROR_MESSAGE + 1];
+	  static int index = 0;
+
+	  line[index++] = c;
+	  if (c == '\n' || index == MAX_ERROR_MESSAGE)
+	    {
+	      line[index] = '\0';
+	      fputs (line, stderr);
+	      index = 0;
+	    }
+	}
     }
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]