[PATCH] Xi: don't crash when deleting invalid device properties.
Peter Hutterer
peter.hutterer at who-t.net
Sun Nov 22 16:35:56 PST 2009
Deleting a property that was not set on a device leads to a null-pointer
dereference. The protocol allows deleting those properties - it has to be a
noop.
Reproducible:
xinput --set-prop "My device" --type=int --format=8 "my property" 1
xinput --delete-prop "My other device" "my property"
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Xi/xiproperty.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index 024dc44..53c947f 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -643,6 +643,9 @@ XIDeleteDeviceProperty (DeviceIntPtr device, Atom property, Bool fromClient)
if (prop->propertyName == property)
break;
+ if (!prop)
+ return BadAtom;
+
if (fromClient && !prop->deletable)
return BadAccess;
@@ -934,6 +937,10 @@ ProcXDeleteDeviceProperty (ClientPtr client)
}
rc = XIDeleteDeviceProperty(dev, stuff->property, TRUE);
+ /* if the property doesn't exist on this device, it's a noop */
+ if (rc == BadAtom)
+ rc = Success;
+
return rc;
}
@@ -1177,6 +1184,10 @@ ProcXIDeleteProperty(ClientPtr client)
}
rc = XIDeleteDeviceProperty(dev, stuff->property, TRUE);
+ /* if the property doesn't exist on this device, it's a noop */
+ if (rc == BadAtom)
+ rc = Success;
+
return rc;
}
--
1.6.5.2
More information about the xorg-devel
mailing list