summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2015-03-23 11:38:15 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2015-03-27 11:23:53 +1000
commitef8daaf696584f7c1d3e9f192de18b5b9f923bdc (patch)
tree57de69161c6d3a66369bc10a664c1ec1a99b1bed
parent90c6d7fc60f3db1bd9db1c7702062fcaef3b3352 (diff)
eventcomm: prevent possibly division by zero
This came up as a kernel bug, but it's valid to create uinput devices with a min == max range for x/y. Technically valid, but effectively useless, so catch it, complain and hobble on along. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> (cherry picked from commit 30866b97be6939b895327b930154ef758eed7ff8)
-rw-r--r--src/eventcomm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/eventcomm.c b/src/eventcomm.c
index 9e81b86..a08a3b3 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -437,6 +437,11 @@ event_query_axis_ranges(InputInfoPtr pInfo)
event_get_abs(proto_data->evdev, ABS_Y, &priv->miny, &priv->maxy,
&priv->synpara.hyst_y, &priv->resy);
+ if (priv->minx == priv->maxx || priv->miny == priv->maxy) {
+ xf86IDrvMsg(pInfo, X_ERROR, "Kernel bug: min == max on ABS_X/Y\n");
+ return;
+ }
+
priv->has_pressure = libevdev_has_event_code(proto_data->evdev, EV_ABS, ABS_PRESSURE);
priv->has_width = libevdev_has_event_code(proto_data->evdev, EV_ABS, ABS_TOOL_WIDTH);
@@ -459,6 +464,11 @@ event_query_axis_ranges(InputInfoPtr pInfo)
event_get_abs(proto_data->evdev, ABS_MT_POSITION_Y, &priv->miny,
&priv->maxy, &priv->synpara.hyst_y, &priv->resy);
+ if (priv->minx == priv->maxx || priv->miny == priv->maxy) {
+ xf86IDrvMsg(pInfo, X_ERROR, "Kernel bug: min == max on ABS_MT_POSITION_X/Y\n");
+ return;
+ }
+
proto_data->st_to_mt_offset[0] = priv->minx - st_minx;
proto_data->st_to_mt_scale[0] =
(priv->maxx - priv->minx) / (st_maxx - st_minx);