[BUG,PATCH] xorg-server
Hello!
I use Debiann/GNU Linux and have an "IBM Corp. SK-8815 Keyboard" which
exports two devices, one regular "PC 105 USB" keyboard, and an extension
for the multimedia keys and buttons to quick-start applications.
I: Bus=0003 Vendor=04b3 Product=301b Version=0110
N: Name="Lite-On Technology USB Productivity Option Keyboard( has the
hub in # 1 )"
P: Phys=usb-0000:00:1a.7-4.3.1/input0
S: Sysfs=/class/input/input2
U: Uniq=
H: Handlers=kbd event2
B: EV=120013
B: KEY=10000 7 ff9f207a c14057ff febeffdf ffefffff ffffffff fffffffe
B: MSC=10
B: LED=1f
I: Bus=0003 Vendor=04b3 Product=301b Version=0110
N: Name="Lite-On Technology USB Productivity Option Keyboard( has the
hub in # 1 )"
P: Phys=usb-0000:00:1a.7-4.3.1/input1
S: Sysfs=/class/input/input3
U: Uniq=
H: Handlers=kbd event3
B: EV=13
B: KEY=ff 0 2000000 3878 d8000001 e0000 0 0 0
B: MSC=10
The "application" buttons are reported as USB-HID-events
256 BTN_0
257 BTN_1
258 BTN_2
259 BTN_3
260 BTN_4
261 BTN_5
262 BTN_6
263 BTN_7
xserver-xorg-input-evdev receives them fine, but since they are above
(255-8), they are SILENTLY discarded and are not passed on. It woule
haven been fine if at least a message was logged somewhere, that buttons
above 255-8 are currently not supported.
xserver-xorg-input-evdev-2.0.3/src/evdev.c:267 PostKbdEventa()
xserver-xorg-input-evdev-2.0.3/src/evdev.c:145 xf86PostKeyboardEvent()
xorg-server-1.4.2/hw/xfree86/common/xf86Xinput.c:694 GetKeyboardEvents()
xorg-server-1.4.2/dix/getevents.c:380 GetKeyboardValuatorEvents()
xorg-server-1.4.2/dix/getevents.c:403
There was one bug filed and "fixed", which "rejects out-of-range keycodes":
http://article.gmane.org/gmane.linux.debian.devel.x/58539
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=443697
https://bugs.freedesktop.org/show_bug.cgi?id=12528
I have a problem with the fix for that bug:
1. The limits are hard-coded to 8 <= key_code <= 255. Isn't
curKeySyms.{min,max}KeyCode supposed to have the actual limits?
2. The range-check is too late, since map[key_code - min] is
dereferenced BEFORE the range-check. I think this only survived because
gcc is clever enouth to have reordered the assignment after the check.
Because of this I propose the following patch:
--- xorg-server-1.4.2/dix/getevents.c~ 2008-09-10 08:44:23.000000000 +0200
+++ xorg-server-1.4.2/dix/getevents.c 2008-09-10 09:04:46.000000000 +0200
@@ -409,9 +409,6 @@ GetKeyboardValuatorEvents(xEvent *events
KeySym sym;
deviceKeyButtonPointer *kbp = NULL;
- sym = map[(key_code - pDev->key->curKeySyms.minKeyCode)
- * pDev->key->curKeySyms.mapWidth];
-
if (!events)
return 0;
@@ -423,7 +420,8 @@ GetKeyboardValuatorEvents(xEvent *events
(pDev->coreEvents && !inputInfo.keyboard->key))
return 0;
- if (key_code < 8 || key_code > 255)
+ if (key_code < pDev->key->curKeySyms.minKeyCode ||
+ key_code > pDev->key->curKeySyms.maxKeyCode)
return 0;
if (pDev->coreEvents)
@@ -437,6 +435,9 @@ GetKeyboardValuatorEvents(xEvent *events
numEvents += (num_valuators / 6) + 1;
}
+ sym = map[(key_code - pDev->key->curKeySyms.minKeyCode)
+ * pDev->key->curKeySyms.mapWidth];
+
#ifdef XKB
if (noXkbExtension)
#endif
I've test-compiled a new x-sever with this patch applied and have run it
successfully.
BYtE
Philipp
--
/ / (_)__ __ ____ __ Philipp Hahn
/ /__/ / _ \/ // /\ \/ /
/____/_/_//_/\_,_/ /_/\_\ pmhahn@titan.lahn.de
Reply to: