[libvirt] [PATCH] [BUGFIX][PATCH] send-key: fix scan keycode map

KAMEZAWA Hiroyuki kamezawa.hiroyu at jp.fujitsu.com
Mon Aug 22 10:02:15 UTC 2011


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: KAMEZAWA Hiroyuki <kamezawa.hiroyu at jp.fujitsu.com>

---
 src/util/virkeycode.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c
index 4d54060..0d42767 100644
--- a/src/util/virkeycode.c
+++ b/src/util/virkeycode.c
@@ -118,7 +118,7 @@ static int __virKeycodeValueTranslate(unsigned int from_offset,
 {
     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)
             return getfield(virKeycodes + i, unsigned short, to_offset);
     }
-- 
1.7.4.1





More information about the libvir-list mailing list