[xf86-input-synaptics v3 01/14] Check if proto_data is valid before derefencing members

Peter Hutterer peter.hutterer at who-t.net
Fri Feb 10 12:12:08 PST 2012


On Fri, Feb 10, 2012 at 11:56:45AM -0800, Chase Douglas wrote:
> proto_data is NULL when run through eventcomm-test.
> 
> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
> ---
>  src/eventcomm.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/eventcomm.c b/src/eventcomm.c
> index ce26934..a52e8b8 100644
> --- a/src/eventcomm.c
> +++ b/src/eventcomm.c
> @@ -502,7 +502,7 @@ SynapticsReadEvent(InputInfoPtr pInfo, struct input_event *ev)
>      ssize_t len;
>  
>  #ifdef HAVE_MTDEV
> -    if (proto_data->mtdev)
> +    if (proto_data && proto_data->mtdev)
>          len = mtdev_get(proto_data->mtdev, pInfo->fd, ev, 1) *
>                sizeof(struct input_event);
>      else
> @@ -598,7 +598,7 @@ EventProcessTouch(InputInfoPtr pInfo)
>      SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
>      struct eventcomm_proto_data *proto_data = priv->proto_data;
>  
> -    if (proto_data->cur_slot < 0 || !priv->has_touch)
> +    if (!proto_data || proto_data->cur_slot < 0 || !priv->has_touch)
>          return;
>  
>      /* If the ABS_MT_SLOT is the first event we get after EV_SYN, skip this */
> -- 
> 1.7.8.3

Not a fan of this tbh, it seems it only checks in the paths hit by the
eventcomm-test. If we're really pulling through with this, we should check
everywhere. The better approach is to allocate some zeroed out array in the
test that is sizeof(eventcomm_proto_data) and use that as priv->proto_data
(since you only care about 0s anyway), or add a simple helper function
void *EventAllocatePrivate();
 
Cheers,
  Peter


More information about the xorg-devel mailing list