* [Qemu-devel] [PATCH v4] hw/display/qxl: fix signed to unsigned comparison
@ 2014-01-20 16:57 Alon Levy
2014-01-21 10:55 ` Gerd Hoffmann
0 siblings, 1 reply; 2+ messages in thread
From: Alon Levy @ 2014-01-20 16:57 UTC (permalink / raw)
To: qemu-devel, kraxel, peter.maydell, armbru
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>
---
hw/display/qxl.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index e4f172e..ceae1d9 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"
@@ -1360,14 +1361,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;
}
--
1.8.4.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v4] hw/display/qxl: fix signed to unsigned comparison
2014-01-20 16:57 [Qemu-devel] [PATCH v4] hw/display/qxl: fix signed to unsigned comparison Alon Levy
@ 2014-01-21 10:55 ` Gerd Hoffmann
0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2014-01-21 10:55 UTC (permalink / raw)
To: Alon Levy; +Cc: peter.maydell, qemu-devel, armbru
On Mo, 2014-01-20 at 18:57 +0200, Alon Levy wrote:
> 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).
Added to spice patch queue.
thanks,
Gerd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-21 10:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-20 16:57 [Qemu-devel] [PATCH v4] hw/display/qxl: fix signed to unsigned comparison Alon Levy
2014-01-21 10:55 ` Gerd Hoffmann
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).