* [Qemu-devel] [PATCH] input: mouse_set should check input device type.
@ 2014-03-30 13:49 Hani Benhabiles
2014-03-31 6:12 ` Gerd Hoffmann
0 siblings, 1 reply; 4+ messages in thread
From: Hani Benhabiles @ 2014-03-30 13:49 UTC (permalink / raw)
To: qemu-devel; +Cc: kraxel, aliguori
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 <hani@linux.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] input: mouse_set should check input device type.
2014-03-30 13:49 [Qemu-devel] [PATCH] input: mouse_set should check input device type Hani Benhabiles
@ 2014-03-31 6:12 ` Gerd Hoffmann
2014-03-31 12:45 ` Markus Armbruster
0 siblings, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2014-03-31 6:12 UTC (permalink / raw)
To: Hani Benhabiles, Markus Armbruster; +Cc: qemu-devel, aliguori
> + 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] input: mouse_set should check input device type.
2014-03-31 6:12 ` Gerd Hoffmann
@ 2014-03-31 12:45 ` Markus Armbruster
2014-03-31 22:10 ` Hani Benhabiles
0 siblings, 1 reply; 4+ messages in thread
From: Markus Armbruster @ 2014-03-31 12:45 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel, Hani Benhabiles, aliguori
Gerd Hoffmann <kraxel@redhat.com> writes:
>> + 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.
>
> Otherwise the patch is fine.
>
> cheers,
> Gerd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] input: mouse_set should check input device type.
2014-03-31 12:45 ` Markus Armbruster
@ 2014-03-31 22:10 ` Hani Benhabiles
0 siblings, 0 replies; 4+ messages in thread
From: Hani Benhabiles @ 2014-03-31 22:10 UTC (permalink / raw)
To: Markus Armbruster; +Cc: Gerd Hoffmann, aliguori, qemu-devel
On Mon, Mar 31, 2014 at 02:45:49PM +0200, Markus Armbruster wrote:
> Gerd Hoffmann <kraxel@redhat.com> writes:
>
> >> + 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.
>
> >
> > Otherwise the patch is fine.
> >
> > cheers,
> > Gerd
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-31 22:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-30 13:49 [Qemu-devel] [PATCH] input: mouse_set should check input device type Hani Benhabiles
2014-03-31 6:12 ` Gerd Hoffmann
2014-03-31 12:45 ` Markus Armbruster
2014-03-31 22:10 ` Hani Benhabiles
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).