From d239f831f17ccf5468f5dc6b2f199a9c1f6e35af Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 5 Sep 2014 14:24:29 +1000 Subject: eventcomm: add missing axis labels to avoid array overrun And warn when we run out of labels. Signed-off-by: Peter Hutterer Reviewed-by: Keith Packard --- src/eventcomm.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/eventcomm.c b/src/eventcomm.c index faaa57d..e789f0e 100644 --- a/src/eventcomm.c +++ b/src/eventcomm.c @@ -843,7 +843,7 @@ event_query_touch(InputInfoPtr pInfo) if (priv->has_touch) { int axnum; - static const char *labels[] = { + static const char *labels[ABS_MT_MAX] = { AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR, AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR, AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR, @@ -855,6 +855,9 @@ event_query_touch(InputInfoPtr pInfo) AXIS_LABEL_PROP_ABS_MT_BLOB_ID, AXIS_LABEL_PROP_ABS_MT_TRACKING_ID, AXIS_LABEL_PROP_ABS_MT_PRESSURE, + AXIS_LABEL_PROP_ABS_MT_DISTANCE, + AXIS_LABEL_PROP_ABS_MT_TOOL_X, + AXIS_LABEL_PROP_ABS_MT_TOOL_Y, }; priv->max_touches = libevdev_get_num_slots(dev); @@ -888,7 +891,13 @@ event_query_touch(InputInfoPtr pInfo) break; default: - priv->touch_axes[axnum].label = labels[axis_idx]; + if (axis_idx >= sizeof(labels)/sizeof(labels[0])) { + xf86IDrvMsg(pInfo, X_ERROR, + "Axis %d out of label range. This is a bug\n", + axis); + priv->touch_axes[axnum].label = NULL; + } else + priv->touch_axes[axnum].label = labels[axis_idx]; priv->touch_axes[axnum].min = libevdev_get_abs_minimum(dev, axis); priv->touch_axes[axnum].max = libevdev_get_abs_maximum(dev, axis); /* Kernel provides units/mm, X wants units/m */ -- cgit v1.2.3