From e2e5932bda3f473629d4be6f3ca4dcab18993eb6 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 16 Apr 2009 11:06:52 +1000 Subject: [PATCH] dix: don't allow more than MAX_VALUATORS on one device. Some keyboards (?) advertise more than MAX_VALUATORS axes. Parts of the internal event delivery relies on not having more than MAX_VALUATOR axes, so let's cap it down. If there's real devices that require more than the current 36, I'm sure we can bump this up. Signed-off-by: Peter Hutterer --- Xi/exevents.c | 2 ++ dix/devices.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/Xi/exevents.c b/Xi/exevents.c index cfae57de1..3f531d961 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1037,6 +1037,8 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval, if (!dev || !dev->valuator || minval > maxval) return; + if (axnum >= dev->valuator->numAxes) + return; ax = dev->valuator->axes + axnum; diff --git a/dix/devices.c b/dix/devices.c index d14eddd72..9f56842f6 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -1081,6 +1081,14 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, if (!dev) return FALSE; + if (numAxes >= MAX_VALUATORS) + { + LogMessage(X_WARNING, + "Device '%s' has %d axes, only using first %d.\n", + dev->name, numAxes, MAX_VALUATORS); + numAxes = MAX_VALUATORS; + } + valc = (ValuatorClassPtr)xcalloc(1, sizeof(ValuatorClassRec) + numAxes * sizeof(AxisInfo) + numAxes * sizeof(unsigned int));