This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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]

[PATCH]: Fix tui status on large width terminal


Hi!

I committed this patch on mainline & 5_3 branch to fix a wrong tui status line
due to buffer overflow in a local buffer (I wish we had used ADA here!).  The buffer
is now allocated with alloca() and allocated according to max width.

	Stephane

2002-09-13  Stephane Carrez  <stcarrez@nerim.fr>

	* tuiStack.c (tui_make_status_line): Make sure the local buffer
	is large enough to hold the complete line.
Index: tuiStack.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiStack.c,v
retrieving revision 1.20
diff -u -p -r1.20 tuiStack.c
--- tuiStack.c	1 Sep 2002 10:20:48 -0000	1.20
+++ tuiStack.c	13 Sep 2002 19:32:46 -0000
@@ -79,8 +79,9 @@ static char*
 tui_make_status_line (TuiLocatorElement* loc)
 {
   char* string;
-  char line_buf[50], buf[50], *pname;
-  int status_size = termWidth ();
+  char line_buf[50], *pname;
+  char* buf;
+  int status_size;
   int i, proc_width;
   const char* pid_name;
   const char* pc_buf;
@@ -102,8 +103,10 @@ tui_make_status_line (TuiLocatorElement*
   pid_width = strlen (pid_name);
   if (pid_width > MAX_PID_WIDTH)
     pid_width = MAX_PID_WIDTH;
-  
+
+  status_size = termWidth ();  
   string = (char *) xmalloc (status_size + 1);
+  buf = (char*) alloca (status_size + 1);
 
   /* Translate line number and obtain its size.  */
   if (loc->lineNo > 0)

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