From: KAMEZAWA Hiroyuki Date: Mon, 22 Aug 2011 10:02:15 +0000 (+0900) Subject: send-key: fix scan keycode map X-Git-Tag: v0.9.5-rc1~188 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f5afc732c5f5b790f1c1006d2d97adb3fa7bb30;p=thirdparty%2Flibvirt.git 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: KAMEZAWA Hiroyuki --- diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c index 4d540607a8..0d427677d6 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); }