|
|
725f84 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
725f84 |
Date: Wed, 29 Oct 2014 12:56:07 +0100
|
|
|
725f84 |
Subject: [PATCH] vmware-vga: add vmsvga_verify_rect
|
|
|
725f84 |
|
|
|
725f84 |
Add verification function for rectangles, returning
|
|
|
725f84 |
true if verification passes and false otherwise.
|
|
|
725f84 |
|
|
|
725f84 |
Cc: qemu-stable@nongnu.org
|
|
|
725f84 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
725f84 |
Reviewed-by: Don Koch <dkoch@verizon.com>
|
|
|
725f84 |
---
|
|
|
725f84 |
hw/display/vmware_vga.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
725f84 |
1 file changed, 52 insertions(+), 1 deletion(-)
|
|
|
725f84 |
|
|
|
725f84 |
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
|
|
|
725f84 |
index 4a4229b..f0e487f 100644
|
|
|
725f84 |
--- a/hw/display/vmware_vga.c
|
|
|
725f84 |
+++ b/hw/display/vmware_vga.c
|
|
|
725f84 |
@@ -294,8 +294,59 @@ enum {
|
|
|
725f84 |
SVGA_CURSOR_ON_RESTORE_TO_FB = 3,
|
|
|
725f84 |
};
|
|
|
725f84 |
|
|
|
725f84 |
+static inline bool vmsvga_verify_rect(DisplaySurface *surface,
|
|
|
725f84 |
+ const char *name,
|
|
|
725f84 |
+ int x, int y, int w, int h)
|
|
|
725f84 |
+{
|
|
|
725f84 |
+ if (x < 0) {
|
|
|
725f84 |
+ fprintf(stderr, "%s: x was < 0 (%d)\n", name, x);
|
|
|
725f84 |
+ return false;
|
|
|
725f84 |
+ }
|
|
|
725f84 |
+ if (x > SVGA_MAX_WIDTH) {
|
|
|
725f84 |
+ fprintf(stderr, "%s: x was > %d (%d)\n", name, SVGA_MAX_WIDTH, x);
|
|
|
725f84 |
+ return false;
|
|
|
725f84 |
+ }
|
|
|
725f84 |
+ if (w < 0) {
|
|
|
725f84 |
+ fprintf(stderr, "%s: w was < 0 (%d)\n", name, w);
|
|
|
725f84 |
+ return false;
|
|
|
725f84 |
+ }
|
|
|
725f84 |
+ if (w > SVGA_MAX_WIDTH) {
|
|
|
725f84 |
+ fprintf(stderr, "%s: w was > %d (%d)\n", name, SVGA_MAX_WIDTH, w);
|
|
|
725f84 |
+ return false;
|
|
|
725f84 |
+ }
|
|
|
725f84 |
+ if (x + w > surface_width(surface)) {
|
|
|
725f84 |
+ fprintf(stderr, "%s: width was > %d (x: %d, w: %d)\n",
|
|
|
725f84 |
+ name, surface_width(surface), x, w);
|
|
|
725f84 |
+ return false;
|
|
|
725f84 |
+ }
|
|
|
725f84 |
+
|
|
|
725f84 |
+ if (y < 0) {
|
|
|
725f84 |
+ fprintf(stderr, "%s: y was < 0 (%d)\n", name, y);
|
|
|
725f84 |
+ return false;
|
|
|
725f84 |
+ }
|
|
|
725f84 |
+ if (y > SVGA_MAX_HEIGHT) {
|
|
|
725f84 |
+ fprintf(stderr, "%s: y was > %d (%d)\n", name, SVGA_MAX_HEIGHT, y);
|
|
|
725f84 |
+ return false;
|
|
|
725f84 |
+ }
|
|
|
725f84 |
+ if (h < 0) {
|
|
|
725f84 |
+ fprintf(stderr, "%s: h was < 0 (%d)\n", name, h);
|
|
|
725f84 |
+ return false;
|
|
|
725f84 |
+ }
|
|
|
725f84 |
+ if (h > SVGA_MAX_HEIGHT) {
|
|
|
725f84 |
+ fprintf(stderr, "%s: h was > %d (%d)\n", name, SVGA_MAX_HEIGHT, h);
|
|
|
725f84 |
+ return false;
|
|
|
725f84 |
+ }
|
|
|
725f84 |
+ if (y + h > surface_height(surface)) {
|
|
|
725f84 |
+ fprintf(stderr, "%s: update height > %d (y: %d, h: %d)\n",
|
|
|
725f84 |
+ name, surface_height(surface), y, h);
|
|
|
725f84 |
+ return false;
|
|
|
725f84 |
+ }
|
|
|
725f84 |
+
|
|
|
725f84 |
+ return true;
|
|
|
725f84 |
+}
|
|
|
725f84 |
+
|
|
|
725f84 |
static inline void vmsvga_update_rect(struct vmsvga_state_s *s,
|
|
|
725f84 |
- int x, int y, int w, int h)
|
|
|
725f84 |
+ int x, int y, int w, int h)
|
|
|
725f84 |
{
|
|
|
725f84 |
DisplaySurface *surface = qemu_console_surface(s->vga.con);
|
|
|
725f84 |
int line;
|