sbonazzo / rpms / qemu

Forked from rpms/qemu a year ago
Clone
f375e62
From eaea06c56ee6569bbd6864a6f767160a74c9c65d Mon Sep 17 00:00:00 2001
5ba1a77
From: Michael Tokarev <mjt@tls.msk.ru>
5ba1a77
Date: Wed, 19 Sep 2012 17:41:26 +0400
5544c1b
Subject: [PATCH] qxl/update_area_io: cleanup invalid parameters handling
5ba1a77
5ba1a77
This cleans up two additions of almost the same code in commits
5ba1a77
511b13e2c9 and ccc2960d654.  While at it, make error paths
5ba1a77
consistent (always use 'break' instead of 'return').
5ba1a77
5ba1a77
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
5ba1a77
Cc: Dunrong Huang <riegamaths@gmail.com>
5ba1a77
Cc: Alon Levy <alevy@redhat.com>
5ba1a77
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5ba1a77
---
5ba1a77
 hw/qxl.c | 13 +++----------
5ba1a77
 1 file changed, 3 insertions(+), 10 deletions(-)
5ba1a77
5ba1a77
diff --git a/hw/qxl.c b/hw/qxl.c
f375e62
index 1aac04b..6b9d5d0 100644
5ba1a77
--- a/hw/qxl.c
5ba1a77
+++ b/hw/qxl.c
5544c1b
@@ -1547,20 +1547,13 @@ async_common:
5ba1a77
         if (d->ram->update_surface > d->ssd.num_surfaces) {
5ba1a77
             qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: invalid surface id %d\n",
5ba1a77
                               d->ram->update_surface);
5ba1a77
-            return;
5ba1a77
+            break;
5ba1a77
         }
5ba1a77
-        if (update.left >= update.right || update.top >= update.bottom) {
5ba1a77
+        if (update.left >= update.right || update.top >= update.bottom ||
5ba1a77
+            update.left < 0 || update.top < 0) {
5ba1a77
             qxl_set_guest_bug(d,
5ba1a77
                     "QXL_IO_UPDATE_AREA: invalid area (%ux%u)x(%ux%u)\n",
5ba1a77
                     update.left, update.top, update.right, update.bottom);
5ba1a77
-            return;
5ba1a77
-        }
5ba1a77
-
5ba1a77
-        if (update.left < 0 || update.top < 0 || update.left >= update.right ||
5ba1a77
-            update.top >= update.bottom) {
5ba1a77
-            qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: "
5ba1a77
-                              "invalid area(%d,%d,%d,%d)\n", update.left,
5ba1a77
-                              update.right, update.top, update.bottom);
5ba1a77
             break;
5ba1a77
         }
5ba1a77
         if (async == QXL_ASYNC) {
5ba1a77
-- 
f375e62
1.8.0.2
5ba1a77