(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.
This commit is contained in:
Richard M. Stallman
2003-08-19 23:47:31 +00:00
parent 5851666e10
commit 3a06a6d99b
2 changed files with 18 additions and 10 deletions

View File

@@ -1,3 +1,12 @@
2003-08-19 Gerd Moellmann <gerd@gnu.org>
* s/freebsd.h [__FreeBSD_version >= 400000]: Define TERMINFO,
use -lncurses.
* term.c (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.
2003-08-19 Miles Bader <miles@gnu.org>
* xterm.c (x_term_init): Correctly use result of Ffile_readable_p.

View File

@@ -2159,7 +2159,8 @@ term_init (terminal_type)
{
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 @@ term_init (terminal_type)
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 @@ term_init (terminal_type)
Wcm_clear ();
buffer = (char *) xmalloc (buffer_size);
status = tgetent (buffer, terminal_type);
if (status < 0)
{
@@ -2229,13 +2228,11 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
terminal_type);
#endif
}
#ifdef TERMINFO
area = (char *) xmalloc (2044);
#else
area = (char *) xmalloc (strlen (buffer));
#endif /* not TERMINFO */
if (area == 0)
if (strlen (buffer) >= buffer_size)
abort ();
area = (char *) xmalloc (strlen (buffer));
TS_ins_line = tgetstr ("al", address);
TS_ins_multi_lines = tgetstr ("AL", address);
@@ -2560,6 +2557,8 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0;
FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none;
#endif /* WINDOWSNT */
xfree (buffer);
}
/* VARARGS 1 */