xserver: Branch 'master' - 2 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Sep 1 23:18:29 UTC 2024
Xi/xichangehierarchy.c | 33 +++++++++++++++++++++++++++------
dix/devices.c | 5 ++++-
2 files changed, 31 insertions(+), 7 deletions(-)
New commits:
commit e7c876ab0b0daa546a23d4ef82537fdf8fd88e04
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Tue Jan 30 11:11:54 2024 +1000
Xi: when removing a master search for a disabled paired device
If either the master pointer or keyboard was disabled, the respective
GetMaster() call returns NULL, causing a segfault later accessing the
deviceid.
Fix this by looking in the off_devices list for any master
device of the type we're looking for. Master devices lose the pairing
when disabled (on enabling a keyboard we simply pair with the first
available unpaired pointer).
And for readability, split the device we get from the protocol request
into a new "dev" variable instead of re-using ptr.
Fixes #1611
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1256>
diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
index 99cc25045..8e7a0dcae 100644
--- a/Xi/xichangehierarchy.c
+++ b/Xi/xichangehierarchy.c
@@ -50,6 +50,7 @@
#include "extnsionst.h"
#include "exglobals.h"
#include "geext.h"
+#include "misc.h"
#include "xace.h"
#include "xiquerydevice.h" /* for GetDeviceUse */
#include "xkbsrv.h"
@@ -217,36 +218,56 @@ disable_clientpointer(DeviceIntPtr dev)
}
}
+static DeviceIntPtr
+find_disabled_master(int type)
+{
+ DeviceIntPtr dev;
+
+ /* Once a master device is disabled it loses the pairing, so returning the first
+ * match is good enough */
+ for (dev = inputInfo.off_devices; dev; dev = dev->next) {
+ if (dev->type == type)
+ return dev;
+ }
+
+ return NULL;
+}
+
static int
remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
{
- DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd;
+ DeviceIntPtr dev, ptr, keybd, XTestptr, XTestkeybd;
int rc = Success;
if (r->return_mode != XIAttachToMaster && r->return_mode != XIFloating)
return BadValue;
- rc = dixLookupDevice(&ptr, r->deviceid, client, DixDestroyAccess);
+ rc = dixLookupDevice(&dev, r->deviceid, client, DixDestroyAccess);
if (rc != Success)
goto unwind;
- if (!IsMaster(ptr)) {
+ if (!IsMaster(dev)) {
client->errorValue = r->deviceid;
rc = BadDevice;
goto unwind;
}
/* XXX: For now, don't allow removal of VCP, VCK */
- if (ptr == inputInfo.pointer ||ptr == inputInfo.keyboard) {
+ if (dev == inputInfo.pointer || dev == inputInfo.keyboard) {
rc = BadDevice;
goto unwind;
}
- ptr = GetMaster(ptr, MASTER_POINTER);
+ if ((ptr = GetMaster(dev, MASTER_POINTER)) == NULL)
+ ptr = find_disabled_master(MASTER_POINTER);
+ BUG_RETURN_VAL(ptr == NULL, BadDevice);
rc = dixLookupDevice(&ptr, ptr->id, client, DixDestroyAccess);
if (rc != Success)
goto unwind;
- keybd = GetMaster(ptr, MASTER_KEYBOARD);
+
+ if ((keybd = GetMaster(dev, MASTER_KEYBOARD)) == NULL)
+ keybd = find_disabled_master(MASTER_KEYBOARD);
+ BUG_RETURN_VAL(keybd == NULL, BadDevice);
rc = dixLookupDevice(&keybd, keybd->id, client, DixDestroyAccess);
if (rc != Success)
goto unwind;
commit 9b983fecf999b9f50946973f2379a5ce00491cad
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Tue Jan 30 10:44:58 2024 +1000
dix: don't push the XKB state to a non-existing master keyboard
If our master keyboard is disabled, GetMaster() returns NULL and
we segfault in XkbPushLockedStateToSlaves().
Fixes 45fb3a934dc0db51584aba37c2f9d73deff9191d
Fixes #1611
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1256>
diff --git a/dix/devices.c b/dix/devices.c
index 48f701be3..b4b15a159 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2699,11 +2699,14 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
dev->spriteInfo->paired = dev;
}
else {
+ DeviceIntPtr keyboard = GetMaster(dev, MASTER_KEYBOARD);
+
dev->spriteInfo->sprite = master->spriteInfo->sprite;
dev->spriteInfo->paired = master;
dev->spriteInfo->spriteOwner = FALSE;
- XkbPushLockedStateToSlaves(GetMaster(dev, MASTER_KEYBOARD), 0, 0);
+ if (keyboard)
+ XkbPushLockedStateToSlaves(keyboard, 0, 0);
RecalculateMasterButtons(master);
}
More information about the xorg-commit
mailing list