Index: main/asterisk.c =================================================================== --- main/asterisk.c (revision 88652) +++ main/asterisk.c (working copy) @@ -1764,7 +1764,8 @@ struct pollfd fds[2]; int res; int max; - char buf[512]; +#define EL_BUF_SIZE 512 + char buf[EL_BUF_SIZE]; for (;;) { max = 1; @@ -1826,7 +1827,7 @@ if (!ast_opt_exec && !lastpos) write(STDOUT_FILENO, "\r", 1); write(STDOUT_FILENO, buf, res); - if ((buf[res-1] == '\n') || (buf[res-2] == '\n')) { + if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (buf[res-2] == '\n'))) { *cp = CC_REFRESH; return(1); } else