diff options
author | Laszlo Ersek <lersek@redhat.com> | 2012-09-17 11:10:03 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@gmail.com> | 2012-09-23 07:11:28 +0100 |
commit | c10600af60865ba6c60987be313102ebb5fcee57 (patch) | |
tree | 7a4db06adde170d4032330d04cddb73f54224dd3 /console.c | |
parent | 995ee2bf469de6bbe5ce133ec853392b2a4ce34c (diff) |
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>
Diffstat (limited to 'console.c')
-rw-r--r-- | console.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -938,8 +938,11 @@ static void console_putchar(TextConsole *s, int ch) case TTY_STATE_CSI: /* handle escape sequence parameters */ if (ch >= '0' && ch <= '9') { if (s->nb_esc_params < MAX_ESC_PARAMS) { - s->esc_params[s->nb_esc_params] = - s->esc_params[s->nb_esc_params] * 10 + ch - '0'; + int *param = &s->esc_params[s->nb_esc_params]; + int digit = (ch - '0'); + + *param = (*param <= (INT_MAX - digit) / 10) ? + *param * 10 + digit : INT_MAX; } } else { if (s->nb_esc_params < MAX_ESC_PARAMS) |