From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUG7z-0006HQ-OG for qemu-devel@nongnu.org; Sun, 30 Mar 2014 09:50:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUG7s-0000y2-9E for qemu-devel@nongnu.org; Sun, 30 Mar 2014 09:50:23 -0400 Received: from mail-ee0-x236.google.com ([2a00:1450:4013:c00::236]:38668) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUG7s-0000xw-28 for qemu-devel@nongnu.org; Sun, 30 Mar 2014 09:50:16 -0400 Received: by mail-ee0-f54.google.com with SMTP id d49so5698375eek.41 for ; Sun, 30 Mar 2014 06:50:15 -0700 (PDT) From: Hani Benhabiles Date: Sun, 30 Mar 2014 14:49:41 +0100 Message-Id: <1396187381-31618-1-git-send-email-kroosec@gmail.com> Subject: [Qemu-devel] [PATCH] input: mouse_set should check input device type. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, aliguori@amazon.com Otherwise, the index of an input device like a usb-kbd is silently accepted. (qemu) info mice Mouse #2: QEMU PS/2 Mouse * Mouse #3: QEMU HID Mouse (qemu) mouse_set 1 (qemu) info mice Mouse #2: QEMU PS/2 Mouse * Mouse #3: QEMU HID Mouse Signed-off-by: Hani Benhabiles --- ui/input.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ui/input.c b/ui/input.c index 2761911..013de95 100644 --- a/ui/input.c +++ b/ui/input.c @@ -342,11 +342,18 @@ void do_mouse_set(Monitor *mon, const QDict *qdict) int found = 0; QTAILQ_FOREACH(s, &handlers, node) { - if (s->id == index) { - found = 1; - qemu_input_handler_activate(s); - break; + if (s->id != index) { + continue; } + if (!(s->handler->mask & (INPUT_EVENT_MASK_REL | + INPUT_EVENT_MASK_ABS))) { + monitor_printf(mon, "Input device '%s' is not a mouse", + s->handler->name); + return; + } + found = 1; + qemu_input_handler_activate(s); + break; } if (!found) { -- 1.8.3.2