From: Roland Dreier <roland@kernel.org>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Roland Dreier <roland@purestorage.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] vnc: tight: Fix crash after 2GB of output
Date: Thu, 3 Mar 2011 16:57:45 -0800 [thread overview]
Message-ID: <1299200265-32685-1-git-send-email-roland@kernel.org> (raw)
From: Roland Dreier <roland@purestorage.com>
If one leaves a VNC session with tight compression running for long
enough, Qemu crashes. This is because of the computation
bytes = zstream->total_out - previous_out;
in tight_compress_data, where zstream->total_out is a uLong but
previous_out is an int. As soon as zstream->total_out gets past
INT_MAX (ie 2GB), previous_out becomes negative and therefore the
result of the subtraction, bytes, becomes a huge positive number that
causes havoc for obvious reasons when passed as a length to
vnc_write().
The fix for this is simple: keep previous_out as a uLong too, which
avoids any problems with sign conversion or truncation.
Signed-off-by: Roland Dreier <roland@purestorage.com>
---
ui/vnc-enc-tight.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index af45edd..59ec0e3 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -829,7 +829,7 @@ static int tight_compress_data(VncState *vs, int stream_id, size_t bytes,
int level, int strategy)
{
z_streamp zstream = &vs->tight.stream[stream_id];
- int previous_out;
+ uLong previous_out;
if (bytes < VNC_TIGHT_MIN_TO_COMPRESS) {
vnc_write(vs, vs->tight.tight.buffer, vs->tight.tight.offset);
next reply other threads:[~2011-03-04 0:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-04 0:57 Roland Dreier [this message]
2011-03-04 7:34 ` [Qemu-devel] [PATCH] vnc: tight: Fix crash after 2GB of output Michael Tokarev
2011-03-04 8:56 ` Corentin Chary
2011-03-04 11:46 ` Michael Tokarev
2011-03-04 21:08 ` Corentin Chary
2011-03-05 5:56 ` [Qemu-devel] [PATCH][STABLE-0.14] " Michael Tokarev
2011-03-05 8:33 ` [Qemu-devel] " Corentin Chary
2011-03-05 8:57 ` Michael Tokarev
2011-03-05 9:29 ` Corentin Chary
2011-03-04 16:59 ` [Qemu-devel] [PATCH] " Roland Dreier
2011-03-04 18:46 ` Roland Dreier
2011-03-04 7:36 ` Michael Tokarev
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=1299200265-32685-1-git-send-email-roland@kernel.org \
--to=roland@kernel.org \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
--cc=roland@purestorage.com \
/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).