From 9c233e23325b8d273a12b36135649b09de816136 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino <lcapitulino@redhat.com> Date: Tue, 22 Nov 2011 20:12:01 +0100 Subject: [PATCH] Fix SIGFPE for vnc display of width/height = 1 RH-Author: Luiz Capitulino <lcapitulino@redhat.com> Message-id: <20111122181201.688bb380@doriath> Patchwork-id: 35107 O-Subject: [PATCH RHEL-5.8 qemu-kvm] Fix SIGFPE for vnc display of width/height = 1 Bugzilla: 751482 RH-Acked-by: Paul Moore <pmoore@redhat.com> RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com> RH-Acked-by: Kevin Wolf <kwolf@redhat.com> Bugzilla: #751482 Upstream-status: merged This is a backport of upstream commit cc39a92cbfc80c70d2b83708a4c9b309c3126ac3 I didn't manage to cherry pick, so I backported it by hand. Fix SIGFPE for vnc display of width/height = 1 During boot, the screen gets resized to height 1 and a mouse click at this point will cause a division by zero when calculating the absolute pointer position from the pixel (x, y). Return a click in the middle of the screen instead in this case. Signed-off-by: Chris Webb <chris@arachsys.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> --- PS: I couldn't reproduce the bug myself. Suqin (from QE) managed to reproduce it with an earlier package, but he can't reproduce it with the latest RHEL5.8 qemu-kvm package nor with this patch applied. qemu/vnc.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) Signed-off-by: Michal Novotny <minovotn@redhat.com> --- qemu/vnc.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qemu/vnc.c b/qemu/vnc.c index c01ec2f..dde462a 100644 --- a/qemu/vnc.c +++ b/qemu/vnc.c @@ -1096,8 +1096,10 @@ static void pointer_event(VncState *vs, int button_mask, int x, int y) dz = 1; if (vs->absolute) { - kbd_mouse_event(x * 0x7FFF / (ds_get_width(vs->ds) - 1), - y * 0x7FFF / (ds_get_height(vs->ds) - 1), + kbd_mouse_event(ds_get_width(vs->ds) > 1 ? + x * 0x7FFF / (ds_get_width(vs->ds) - 1) : 0x4000, + ds_get_height(vs->ds) > 1 ? + y * 0x7FFF / (ds_get_height(vs->ds) - 1) : 0x4000, dz, buttons); } else if (vs->has_pointer_type_change) { x -= 0x7FFF; -- 1.7.7.3