[PATCH] Xi: limit valuator copy to valuator array size (#59939)

Alan Coopersmith alan.coopersmith at oracle.com
Mon Jan 28 17:12:31 PST 2013


On 01/28/13 05:06 PM, Peter Hutterer wrote:
> mask[(MAX_VALUATORS + 7)/8] is larger than data[MAX_VALUATORS], so static
> code checkers think we may be running OOB on the data array. Mask is
> initialized to 0, so this should not happen, but change it anyway to shut up
> code analyzer noise.
> 
> X.Org Bug 59939 <http://bugs.freedesktop.org/show_bug.cgi?id=59939>
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  Xi/exevents.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Xi/exevents.c b/Xi/exevents.c
> index 74f3610..609b126 100644
> --- a/Xi/exevents.c
> +++ b/Xi/exevents.c
> @@ -1263,7 +1263,7 @@ TouchCopyValuatorData(DeviceEvent *ev, TouchPointInfoPtr ti)
>  {
>      int i;
>  
> -    for (i = 0; i < sizeof(ev->valuators.mask) * 8; i++)
> +    for (i = 0; i < ARRAY_SIZE(ev->valuators.data); i++)
>          if (BitIsOn(ev->valuators.mask, i))
>              valuator_mask_set_double(ti->valuators, i, ev->valuators.data[i]);
>  }

Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg-devel mailing list