TextConsole: saturate escape parameter in TTY_STATE_CSI
Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
This commit is contained in:
parent
995ee2bf46
commit
c10600af60
@ -938,8 +938,11 @@ static void console_putchar(TextConsole *s, int ch)
|
|||||||
case TTY_STATE_CSI: /* handle escape sequence parameters */
|
case TTY_STATE_CSI: /* handle escape sequence parameters */
|
||||||
if (ch >= '0' && ch <= '9') {
|
if (ch >= '0' && ch <= '9') {
|
||||||
if (s->nb_esc_params < MAX_ESC_PARAMS) {
|
if (s->nb_esc_params < MAX_ESC_PARAMS) {
|
||||||
s->esc_params[s->nb_esc_params] =
|
int *param = &s->esc_params[s->nb_esc_params];
|
||||||
s->esc_params[s->nb_esc_params] * 10 + ch - '0';
|
int digit = (ch - '0');
|
||||||
|
|
||||||
|
*param = (*param <= (INT_MAX - digit) / 10) ?
|
||||||
|
*param * 10 + digit : INT_MAX;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (s->nb_esc_params < MAX_ESC_PARAMS)
|
if (s->nb_esc_params < MAX_ESC_PARAMS)
|
||||||
|
Loading…
Reference in New Issue
Block a user