qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Prevent SEGV in VNC server for old clients
@ 2008-05-18  2:34 Anthony Liguori
  0 siblings, 0 replies; only message in thread
From: Anthony Liguori @ 2008-05-18  2:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Liguori, Marcelo Tosatti

If the client does not support the DesktopResize pseudo-encoding, then
vs->{width,height} may be smaller than ds->{width,height}.  dirty_row is sized
according to vs->{width,height}, not ds->{width,height}.

This patch makes sure to bound the update region to vs->{width,height} to avoid
a possible SEGV.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Reported-by: Marcelo Tosatti <mtosatti@redhat.com>

diff --git a/vnc.c b/vnc.c
index 842124b..4b57838 100644
--- a/vnc.c
+++ b/vnc.c
@@ -265,6 +265,11 @@ static void vnc_dpy_update(DisplayState *ds, int x, int y, int w, int h)
     w += (x % 16);
     x -= (x % 16);
 
+    x = MIN(x, vs->width);
+    y = MIN(y, vs->height);
+    w = MIN(x + w, vs->width) - x;
+    h = MIN(y + h, vs->height) - y;
+
     for (; y < h; y++)
 	for (i = 0; i < w; i += 16)
 	    vnc_set_bit(vs->dirty_row[y], (x + i) / 16);

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-05-18  2:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-18  2:34 [Qemu-devel] [PATCH] Prevent SEGV in VNC server for old clients Anthony Liguori

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).