summaryrefslogtreecommitdiff
path: root/libcaribou
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@unixuser.org>2013-01-10 18:19:37 +0900
committerDaiki Ueno <ueno@unixuser.org>2013-01-11 11:48:06 +0900
commit4fd57133bb0f835f0f5847a6b25c580793ecc5d9 (patch)
treeb941c4380b24ef5d100e4deaeb93ab6fadef556b /libcaribou
parent4a9bda26a803f48122a4a72abe1ef7a507bee52d (diff)
downloadcaribou-4fd57133bb0f835f0f5847a6b25c580793ecc5d9.tar.gz
libcaribou: avoid integer overflow
Since Xkb.Desc.{min,max}_keycode and Xkb.SymMap.width are defined as uchar, for-loops over them with an uchar index may not stop, if the upper bound is uchar.MAX or the lower bound is 0. https://bugzilla.gnome.org/show_bug.cgi?id=691463
Diffstat (limited to 'libcaribou')
-rw-r--r--libcaribou/xadapter.vala10
1 files changed, 5 insertions, 5 deletions
diff --git a/libcaribou/xadapter.vala b/libcaribou/xadapter.vala
index 62ec4cc..c7c314d 100644
--- a/libcaribou/xadapter.vala
+++ b/libcaribou/xadapter.vala
@@ -127,9 +127,9 @@ namespace Caribou {
}
private uchar keysym_to_modifier (uint keyval) {
- for (var i = xkbdesc.min_key_code; i <= xkbdesc.max_key_code; i++) {
+ for (int i = xkbdesc.min_key_code; i <= xkbdesc.max_key_code; i++) {
unowned Xkb.SymMap symmap = xkbdesc.map.key_sym_map[i];
- for (var j = 0;
+ for (int j = 0;
j < symmap.width * (symmap.group_info & 0x0f);
j++)
if (xkbdesc.map.syms[symmap.offset + j] == keyval)
@@ -139,12 +139,12 @@ namespace Caribou {
}
private uchar get_reserved_keycode () {
- uchar i;
+ int i;
unowned Xkb.Desc xkbdesc = this.xkbdesc;
for (i = xkbdesc.max_key_code; i >= xkbdesc.min_key_code; --i) {
if (xkbdesc.map.key_sym_map[i].kt_index[0] == Xkb.OneLevelIndex) {
- if (this.xdisplay.keycode_to_keysym (i, 0) != 0) {
+ if (this.xdisplay.keycode_to_keysym ((uchar) i, 0) != 0) {
Gdk.error_trap_push ();
this.xdisplay.grab_key (i, 0,
Gdk.x11_get_default_root_xwindow (), true,
@@ -153,7 +153,7 @@ namespace Caribou {
this.xdisplay.ungrab_key (
i, 0, Gdk.x11_get_default_root_xwindow ());
if (Gdk.error_trap_pop () == 0)
- return i;
+ return (uchar) i;
}
}
}