input: mouse_set should check input device type.
PATCH 1/1 input: mouse_set should check input device type.
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
--- ui/input.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
ui/input.c +11 -4
@@ -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) {
Signature · 1 line
1.8.3.2
ui/input.c void do_mouse_set(Monitor *mon, const QDict *qdict) · line 351
Quoted 5 lines
ui/input.c +4
-0+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);
That should be error_report (I think, Markus?).
Otherwise the patch is fine.
cheers,
Gerd
Quoted 6 lines · Gerd Hoffmann
ui/input.c void do_mouse_set(Monitor *mon, const QDict *qdict) · line 351
Quoted 4 lines
ui/input.c +4
-0+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);That should be
error_report(I think, Markus?).
Yes, please. Same for the "Mouse at given index not found\n" message further down. Note that error_report() does *not* want \n.
Quoted 5 lines
Otherwise the patch is fine.
cheers,
Gerd
Quoted 11 lines · Markus Armbruster
Quoted 6 lines · Gerd Hoffmann
ui/input.c void do_mouse_set(Monitor *mon, const QDict *qdict) · line 351
Quoted 4 lines
ui/input.c +4
-0+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);That should be
error_report(I think, Markus?).Yes, please. Same for the "Mouse at given index not found\n" message further down. Note that
error_report()does *not* want \n.
Ok, thanks.
I just followed the other monitor_printf() usage for consistency. v2 sent.
Quoted 6 lines
Quoted 6 lines
Otherwise the patch is fine.
cheers,
Gerd