mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-25 07:01:09 +00:00
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
This commit is contained in:
@@ -2708,13 +2708,14 @@ static int ast_el_read_char(EditLine *editline, char *cp)
|
|||||||
|
|
||||||
console_print(buf, 0);
|
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;
|
*cp = CC_REFRESH;
|
||||||
return(1);
|
return(1);
|
||||||
} else
|
} else {
|
||||||
lastpos = 1;
|
lastpos = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
return (0);
|
return (0);
|
||||||
|
Reference in New Issue
Block a user