From eac3ec53eeaaacb75ae673981c85aafaae5e25ad Mon Sep 17 00:00:00 2001
Message-Id: <eac3ec53eeaaacb75ae673981c85aafaae5e25ad.1350312451.git.minovotn@redhat.com>
In-Reply-To: <aa2da19f266f7dd7345db5620ee362446fc6e806.1350312451.git.minovotn@redhat.com>
References: <aa2da19f266f7dd7345db5620ee362446fc6e806.1350312451.git.minovotn@redhat.com>
From: Alon Levy <alevy@redhat.com>
Date: Sun, 7 Oct 2012 15:31:57 +0200
Subject: [PATCH 20/27] qxl/update_area_io: guest_bug on invalid parameters

RH-Author: Alon Levy <alevy@redhat.com>
Message-id: <1349623920-19894-14-git-send-email-alevy@redhat.com>
Patchwork-id: 42788
O-Subject: [PATCH RHEL-6.4 v2 13/16] qxl/update_area_io: guest_bug on invalid parameters
Bugzilla: 770842
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Arnon Gilboa <agilboa@redhat.com>

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Upstream: 511b13e2c9b426b3c56060909693de5097f0b496
---
 hw/qxl.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/qxl.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/qxl.c b/hw/qxl.c
index 3862f15..73c7ad2 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1406,6 +1406,18 @@ async_common:
         QXLCookie *cookie = NULL;
         QXLRect update = d->ram->update_area;
 
+        if (d->ram->update_surface > NUM_SURFACES) {
+            qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: invalid surface id %d\n",
+                              d->ram->update_surface);
+            return;
+        }
+        if (update.left >= update.right || update.top >= update.bottom) {
+            qxl_set_guest_bug(d,
+                    "QXL_IO_UPDATE_AREA: invalid area (%ux%u)x(%ux%u)\n",
+                    update.left, update.top, update.right, update.bottom);
+            return;
+        }
+
         if (async == QXL_ASYNC) {
             cookie = qxl_cookie_new(QXL_COOKIE_TYPE_IO,
                                     QXL_IO_UPDATE_AREA_ASYNC);
-- 
1.7.11.7

