5780e59c4 "Take scroll buttons into accounts when allocating buttons." added
a conditional to always have at least 7 buttons for devices with more than 3
buttons. The exact number is nbuttons + 4, but for serial devices nbuttons
is always WCM_MAX_MOUSE_BUTTONS - resulting in a segfault later on when
arrays are accessed OOB.

Reported-by: Ping Cheng <[email protected]>
Signed-off-by: Peter Hutterer <[email protected]>
---
Ping, I think this should fix your crash with the isdv4 branch.

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

diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index 8656e63..3809dab 100644
--- a/src/xf86Wacom.c
+++ b/src/xf86Wacom.c
@@ -608,7 +608,8 @@ static int wcmRegisterX11Devices (LocalDevicePtr local)
 
        /* if more than 3 buttons, offset by the four scroll buttons,
         * otherwise, alloc 7 buttons for scroll wheel. */
-       nbbuttons = (nbbuttons > 3) ? nbbuttons + 4 : 7;
+       if (nbuttons <= WCM_MAX_BUTTONS)
+               nbbuttons = (nbbuttons > 3) ? nbbuttons + 4 : 7;
        nbkeys = nbbuttons;         /* Same number of keys since any button may 
be 
                                     * configured as an either mouse button or 
key */
 
-- 
1.6.6.1


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to