From: Laszlo Ersek <lersek@redhat.com>
To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org,
armbru@redhat.com, lersek@redhat.com
Subject: [Qemu-devel] [PATCH] TextConsole: saturate escape parameter in TTY_STATE_CSI
Date: Mon, 17 Sep 2012 11:10:03 +0200 [thread overview]
Message-ID: <1347873003-11593-1-git-send-email-lersek@redhat.com> (raw)
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
next reply other threads:[~2012-09-17 9:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-17 9:10 Laszlo Ersek [this message]
2012-09-17 11:56 ` [Qemu-devel] [PATCH] TextConsole: saturate escape parameter in TTY_STATE_CSI Markus Armbruster
2012-09-22 16:13 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1347873003-11593-1-git-send-email-lersek@redhat.com \
--to=lersek@redhat.com \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).