On Wed, Dec 16, 2009 at 10:17:58PM +0000, Przemysław Firszt wrote:
> Dnia 2009-12-10, czw o godzinie 16:07 +1000, Peter Hutterer pisze:
> [..]
> > The code is fairly straightforward, so feel free to send patches to fix
> > whatever is broken.
> 
> Hi,
> Testcase: xsetwacom --set "WACOM Pen Tablet cursor" "TopY" "0"
> Result: SIGSEGV
> Reason: uninitialised variable used to calloc memory in strjoinsplit
> Solution: see attached patch

oops. thanks for the patch, see the comment below though.
 
> The patch solves SIGSEGV, but now I got this:
> 
> [prz...@pldmachine xf86-input-wacom]$  /usr/bin/xsetwacom --set "WACOM
> Pen Tablet cursor" "TopY" "0"
> X Error of failed request:  BadValue (integer parameter out of range for
> operation)
>   Major opcode of failed request:  139 (XInputExtension)
>   Minor opcode of failed request:  37 (X_ChangeDeviceProperty)
>   Value in failed request:  0x22b
>   Serial number of failed request:  15
>   Current serial number in output stream:  15
> 
> I'll try to fix it later as we all need to sleep sometimes ;-)

changing any of Top/Bottom X/Y is currently broken. The code is based on a
misunderstanding of mine in regards to the areas, so any modification of it
will trigger the overlap check and thus fail.

I'm talking to Ping about this, I'm still struggling to understand how the
areas work. It certainly is a bit more complex than I originally thought.

> From 965686252a0a95587d8a99937c0fb5de25b8269a Mon Sep 17 00:00:00 2001
> From: Przemo Firszt <[email protected]>
> Date: Wed, 16 Dec 2009 22:01:34 +0000
> Subject: [PATCH] Initialise nvals to avoid SIGSEGV
> 
> Uninitialised nvals was used to calloc memory causing random SIGSEGV
> Signed-off-by: Przemo Firszt <[email protected]>
> ---
>  tools/xsetwacom.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
> index cbc2ea2..52e730e 100644
> --- a/tools/xsetwacom.c
> +++ b/tools/xsetwacom.c
> @@ -1474,7 +1474,7 @@ static void set(Display *dpy, int argc, char **argv)
>       char *b;
>       int i;
>       char **values;
> -     int nvals;
> +     int nvals = 0;
>  
>       if (argc < 3)
>       {
> -- 
> 1.6.5.2

nvals is used as a return value only, so strjoinsplit shouldn't rely on any
value being set by the caller. I'd prefer the patch below instead:

Cheers,
  Peter

From 9f51e39a9cb1c0b6eae26fd013869259947ebea5 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <[email protected]>
Date: Thu, 17 Dec 2009 10:24:00 +1000
Subject: [PATCH] xsetwacom: init nwords to 0 before adding to it in 
strjoinsplit.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

nwords is a return value and needs to be initialized before adding to it.

Reported-by: Przemysław Firszt <[email protected]>
Signed-off-by: Peter Hutterer <[email protected]>
---
 tools/xsetwacom.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 7a56332..3adb2d3 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -1150,6 +1150,8 @@ static char** strjoinsplit(int argc, char **argv, int 
*nwords)
                strcat(buff, " ");
        }
 
+       *nwords = 0;
+
        for (tmp = buff; tmp && *tmp != '\0'; tmp = index((const char*)tmp, ' 
') + 1)
                (*nwords)++;
 
-- 
1.6.5.2


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to