提交 9f5afc73 编写于 作者: K KAMEZAWA Hiroyuki 提交者: Eric Blake

send-key: fix scan keycode map

Now, bad key-code in send-key can cause segmentation fault in libvirt.
(example)
 % virsh send-key --codeset win32 12
   error: End of file while reading data: Input/output error

This is caused by overrun at scanning keycode array.

Fix it.
Signed-off-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
上级 6611d9eb
...@@ -118,7 +118,7 @@ static int __virKeycodeValueTranslate(unsigned int from_offset, ...@@ -118,7 +118,7 @@ static int __virKeycodeValueTranslate(unsigned int from_offset,
{ {
int i; int i;
for (i = 0; ARRAY_CARDINALITY(virKeycodes); i++) { for (i = 0; i < ARRAY_CARDINALITY(virKeycodes); i++) {
if (getfield(virKeycodes + i, unsigned short, from_offset) == key_value) if (getfield(virKeycodes + i, unsigned short, from_offset) == key_value)
return getfield(virKeycodes + i, unsigned short, to_offset); return getfield(virKeycodes + i, unsigned short, to_offset);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册