changeset 52265:84e49afb2178

(term_init): Use a buffer of size 4096 for tgetent since FreeBSD returns something longer than 2044. Abort if the end of the buffer is overwritten.
author Richard M. Stallman <rms@gnu.org>
date Tue, 19 Aug 2003 23:47:22 +0000
parents bce3e111b233
children 29a54e360c88
files src/term.c
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/term.c	Tue Aug 19 23:47:04 2003 +0000
+++ b/src/term.c	Tue Aug 19 23:47:22 2003 +0000
@@ -2159,7 +2159,8 @@
 {
   char *area;
   char **address = &area;
-  char buffer[2044];
+  char *buffer = NULL;
+  const int buffer_size = 4096;
   register char *p;
   int status;
   struct frame *sf = XFRAME (selected_frame);
@@ -2171,9 +2172,6 @@
 
   area = (char *) xmalloc (2044);
 
-  if (area == 0)
-    abort ();
-
   FrameRows = FRAME_LINES (sf);
   FrameCols = FRAME_COLS (sf);
   specified_window = FRAME_LINES (sf);
@@ -2202,6 +2200,7 @@
 
   Wcm_clear ();
 
+  buffer = (char *) xmalloc (buffer_size);
   status = tgetent (buffer, terminal_type);
   if (status < 0)
     {
@@ -2229,13 +2228,11 @@
 	     terminal_type);
 #endif
     }
-#ifdef TERMINFO
-  area = (char *) xmalloc (2044);
-#else
+
+  if (strlen (buffer) >= buffer_size)
+    abort ();
+  
   area = (char *) xmalloc (strlen (buffer));
-#endif /* not TERMINFO */
-  if (area == 0)
-    abort ();
 
   TS_ins_line = tgetstr ("al", address);
   TS_ins_multi_lines = tgetstr ("AL", address);
@@ -2560,6 +2557,8 @@
   FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0;
   FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none;
 #endif /* WINDOWSNT */
+
+  xfree (buffer);
 }
 
 /* VARARGS 1 */