qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] input: mouse_set should check input device type.


From: Hani Benhabiles
Subject: [Qemu-devel] [PATCH] input: mouse_set should check input device type.
Date: Sun, 30 Mar 2014 14:49:41 +0100

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]