From: Serge Hallyn <serge.hallyn@canonical.com>
To: Ryan Harper <ryanh@us.ibm.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/1] vmware_vga: stop crashing
Date: Mon, 5 Mar 2012 13:33:47 -0600 [thread overview]
Message-ID: <20120305193347.GA31914@peqn> (raw)
In-Reply-To: <20120302212030.GP21784@us.ibm.com>
if x or y < 0, set them to 0 (and decrement width/height accordingly)>
I don't know where the best place to catch this would be, but
with vnc and vmware_vga it's possible to get set_bit called on
a negative index, crashing qemu. See
https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/918791
for details. This patch prevents that. It's possible this
should be caught earlier, but this patch works for me.
Changelog:
Mar 5: As Ryan Harper pointed out, don't mix tabs+spaces,
and put {} around all conditionals.
Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
---
hw/vmware_vga.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 142d9f4..c94f9f3 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -298,6 +298,24 @@ static inline void vmsvga_update_rect(struct vmsvga_state_s *s,
uint8_t *src;
uint8_t *dst;
+ if (x < 0) {
+ fprintf(stderr, "%s: update x was < 0 (%d, w %d)\n",
+ __FUNCTION__, x, w);
+ w += x;
+ if (w < 0) {
+ return;
+ }
+ x = 0;
+ }
+ if (y < 0) {
+ fprintf(stderr, "%s: update y was < 0 (%d, h %d)\n",
+ __FUNCTION__, y, h);
+ h += y;
+ if (h < 0) {
+ return;
+ }
+ y = 0;
+ }
if (x + w > s->width) {
fprintf(stderr, "%s: update width too large x: %d, w: %d\n",
__FUNCTION__, x, w);
--
1.7.9
next prev parent reply other threads:[~2012-03-05 19:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-02 21:11 [Qemu-devel] [RFC] fix crashes with vmware driver Serge Hallyn
2012-03-02 21:20 ` Ryan Harper
2012-03-05 19:33 ` Serge E. Hallyn
2012-03-05 19:33 ` Serge Hallyn [this message]
2012-03-11 16:56 ` [Qemu-devel] [PATCH 1/1] vmware_vga: stop crashing Gerhard Wiesinger
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=20120305193347.GA31914@peqn \
--to=serge.hallyn@canonical.com \
--cc=qemu-devel@nongnu.org \
--cc=ryanh@us.ibm.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).