Xi: require a pointer and keyboard device for XIAttachToMaster

If we remove a master device and specify which other master devices
attached slaves should be returned to, enforce that those two are
indeeed a pointer and a keyboard.

Otherwise we can try to attach the keyboards to pointers and vice versa,
leading to possible crashes later.
This commit is contained in:
Peter Hutterer 2023-12-21 14:10:11 +10:00
parent f59871587e
commit 37539cb0bf

View File

@ -270,7 +270,7 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
if (rc != Success)
goto unwind;
if (!IsMaster(newptr)) {
if (!IsMaster(newptr) || !IsPointerDevice(newptr)) {
client->errorValue = r->return_pointer;
rc = BadDevice;
goto unwind;
@ -281,7 +281,7 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
if (rc != Success)
goto unwind;
if (!IsMaster(newkeybd)) {
if (!IsMaster(newkeybd) || !IsKeyboardDevice(newkeybd)) {
client->errorValue = r->return_keyboard;
rc = BadDevice;
goto unwind;