qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] TextConsole: saturate escape parameter in TTY_STATE_CSI
@ 2012-09-17  9:10 Laszlo Ersek
  2012-09-17 11:56 ` Markus Armbruster
  2012-09-22 16:13 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
  0 siblings, 2 replies; 3+ messages in thread
From: Laszlo Ersek @ 2012-09-17  9:10 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial, armbru, lersek

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Build tested.
 console.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/console.c b/console.c
index c1ed5e0..67080f4 100644
--- a/console.c
+++ b/console.c
@@ -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)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-22 16:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-17  9:10 [Qemu-devel] [PATCH] TextConsole: saturate escape parameter in TTY_STATE_CSI Laszlo Ersek
2012-09-17 11:56 ` Markus Armbruster
2012-09-22 16:13 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).