From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Hani Benhabiles <hani@linux.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Hani Benhabiles <kroosec@gmail.com>,
Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 2/3] input: mouse_set should check input device type.
Date: Tue, 1 Apr 2014 11:18:26 +0200 [thread overview]
Message-ID: <1396343907-31756-3-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1396343907-31756-1-git-send-email-kraxel@redhat.com>
From: Hani Benhabiles <kroosec@gmail.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
Also replace monitor_printf() call in do_mouse_set() with error_report() and
adjust error message.
Signed-off-by: Hani Benhabiles <hani@linux.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/input.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/ui/input.c b/ui/input.c
index 2761911..6e6a924 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -342,15 +342,21 @@ 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))) {
+ error_report("Input device '%s' is not a mouse", s->handler->name);
+ return;
+ }
+ found = 1;
+ qemu_input_handler_activate(s);
+ break;
}
if (!found) {
- monitor_printf(mon, "Mouse at given index not found\n");
+ error_report("Mouse at index '%d' not found", index);
}
qemu_input_check_mode_change();
--
1.8.3.1
next prev parent reply other threads:[~2014-04-01 9:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-01 9:18 [Qemu-devel] [PULL for-2.0 0/3] input bugfixes Gerd Hoffmann
2014-04-01 9:18 ` [Qemu-devel] [PULL 1/3] input: fix input_event_key_number trace event Gerd Hoffmann
2014-04-01 9:18 ` Gerd Hoffmann [this message]
2014-04-01 9:18 ` [Qemu-devel] [PULL 3/3] input: add sanity check Gerd Hoffmann
2014-04-01 17:15 ` [Qemu-devel] [PULL for-2.0 0/3] input bugfixes Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1396343907-31756-3-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=aliguori@amazon.com \
--cc=hani@linux.com \
--cc=kroosec@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).