aboutsummaryrefslogtreecommitdiff
path: root/hw/display
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2014-01-20 18:57:12 +0200
committerGerd Hoffmann <kraxel@redhat.com>2014-02-03 11:05:15 +0100
commit3761abb167847e9d848588bf15c5d7476845f7e8 (patch)
tree9b0264463c24eeb7ee8f5c5b8583cff5e7630448 /hw/display
parentf06b85218a41fd6f8e797a925f4ea75640b69c9e (diff)
downloadqemu-3761abb167847e9d848588bf15c5d7476845f7e8.zip
qemu-3761abb167847e9d848588bf15c5d7476845f7e8.tar.gz
qemu-3761abb167847e9d848588bf15c5d7476845f7e8.tar.bz2
hw/display/qxl: fix signed to unsigned comparison
Several small signedness / overflow corrections to qxl_create_guest_primary: 1. use 64 bit unsigned for size to avoid overflow possible from two 32 bit multiplicants. 2. correct sign for requested_height 3. add a more verbose error message when setting guest bug state (which causes a complete guess blackout until reset, so it helps if it is verbose). Signed-off-by: Alon Levy <alevy@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/display')
-rw-r--r--hw/display/qxl.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 56b61c8..334c271 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -19,6 +19,7 @@
*/
#include <zlib.h>
+#include <stdint.h>
#include "qemu-common.h"
#include "qemu/timer.h"
@@ -1361,14 +1362,16 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm,
{
QXLDevSurfaceCreate surface;
QXLSurfaceCreate *sc = &qxl->guest_primary.surface;
- int size;
- int requested_height = le32_to_cpu(sc->height);
+ uint32_t requested_height = le32_to_cpu(sc->height);
int requested_stride = le32_to_cpu(sc->stride);
- size = abs(requested_stride) * requested_height;
- if (size > qxl->vgamem_size) {
- qxl_set_guest_bug(qxl, "%s: requested primary larger then framebuffer"
- " size", __func__);
+ if (requested_stride == INT32_MIN ||
+ abs(requested_stride) * (uint64_t)requested_height
+ > qxl->vgamem_size) {
+ qxl_set_guest_bug(qxl, "%s: requested primary larger than framebuffer"
+ " stride %d x height %" PRIu32 " > %" PRIu32,
+ __func__, requested_stride, requested_height,
+ qxl->vgamem_size);
return;
}