From: Diederik de Groot Date: Mon, 18 Jan 2016 09:49:48 +0000 (+0100) Subject: main/asterisk.c: ast_el_read_char X-Git-Tag: 14.0.0-beta1~444^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b259ac95acefd67a90a451f55acab7fd6ce77d97;p=thirdparty%2Fasterisk.git main/asterisk.c: ast_el_read_char Make sure buf[res] is not accessed at res=-1 (buffer underrun). Address Sanitizer will complain about this quite loudly. ASTERISK-24801 #close Change-Id: Ifcd7f691310815a31756b76067c56fba299d3ae9 --- diff --git a/main/asterisk.c b/main/asterisk.c index a7842a6ab6..ca560cdb27 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -2708,11 +2708,12 @@ static int ast_el_read_char(EditLine *editline, char *cp) console_print(buf, 0); - if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (buf[res-2] == '\n'))) { + if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (res >= 2 && buf[res-2] == '\n'))) { *cp = CC_REFRESH; return(1); - } else + } else { lastpos = 1; + } } }