[PATCH 1/2] Xi: always return BadMatch for XTest devices ChangeDeviceControl requests

Peter Hutterer peter.hutterer at who-t.net
Mon Feb 25 19:35:49 PST 2013


The only controls that still do something are DEVICE_RESOLUTION and
DEVICE_ENABLE.

XTest devices have no resolution to change, and they cannot be disabled. So
skip the lot, and prevent a crash in the DDX when it's trying to
de-reference pInfo->control_proc on device with no pInfo struct.

Likewise, don't allow setting device mode or the valuators.
XTest pointers are always relative, they don't have a mode.

Test cases:
xts5/XI/ChangeDeviceControl (1/10)
xts5/XI/SetDeviceValuators (1/6)
and a few others

Reported-by: Knut Petersen <Knut_Petersen at t-online.de>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xi/chgdctl.c | 6 ++++++
 Xi/setdval.c | 3 +++
 Xi/setmode.c | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index 31d3a57..d078aa2 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -122,6 +122,12 @@ ProcXChangeDeviceControl(ClientPtr client)
     if (ret != Success)
         goto out;
 
+    /* XTest devices are special, none of the below apply to them anyway */
+    if (IsXTestDevice(dev, NULL)) {
+        ret = BadMatch;
+        goto out;
+    }
+
     rep = (xChangeDeviceControlReply) {
         .repType = X_Reply,
         .RepType = X_ChangeDeviceControl,
diff --git a/Xi/setdval.c b/Xi/setdval.c
index 4c9c99f..463e4f3 100644
--- a/Xi/setdval.c
+++ b/Xi/setdval.c
@@ -110,6 +110,9 @@ ProcXSetDeviceValuators(ClientPtr client)
     if (dev->valuator == NULL)
         return BadMatch;
 
+    if (IsXTestDevice(dev, NULL))
+        return BadMatch;
+
     if (stuff->first_valuator + stuff->num_valuators > dev->valuator->numAxes)
         return BadValue;
 
diff --git a/Xi/setmode.c b/Xi/setmode.c
index 5356552..5ed0913 100644
--- a/Xi/setmode.c
+++ b/Xi/setmode.c
@@ -104,6 +104,10 @@ ProcXSetDeviceMode(ClientPtr client)
         return rc;
     if (dev->valuator == NULL)
         return BadMatch;
+
+    if (IsXTestDevice(dev, NULL))
+        return BadMatch;
+
     if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client))
         rep.status = AlreadyGrabbed;
     else
-- 
1.8.1.2



More information about the xorg-devel mailing list