diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2023-12-13 06:20:17 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2023-12-13 06:20:17 +0000 |
commit | 592bc6c3d46fa7a999b90faa396be4eb629fbeac (patch) | |
tree | af15f156adb50f5e5a389d9b461eaa04e657e9a1 /xserver/dix | |
parent | 8aee24721d38be66987137fa8df1d7af01b49d47 (diff) |
Xi: allocate enough XkbActions for our buttons
CVE-2023-6377
Diffstat (limited to 'xserver/dix')
-rw-r--r-- | xserver/dix/devices.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/xserver/dix/devices.c b/xserver/dix/devices.c index 5bf956ead..ed8c5aee7 100644 --- a/xserver/dix/devices.c +++ b/xserver/dix/devices.c @@ -2525,6 +2525,8 @@ RecalculateMasterButtons(DeviceIntPtr slave) if (master->button && master->button->numButtons != maxbuttons) { int i; + int last_num_buttons = master->button->numButtons; + DeviceChangedEvent event = { .header = ET_Internal, .type = ET_DeviceChanged, @@ -2535,6 +2537,15 @@ RecalculateMasterButtons(DeviceIntPtr slave) }; master->button->numButtons = maxbuttons; + if (last_num_buttons < maxbuttons) { + master->button->xkb_acts = xnfreallocarray(master->button->xkb_acts, + maxbuttons, + sizeof(XkbAction)); + memset(&master->button->xkb_acts[last_num_buttons], + 0, + (maxbuttons - last_num_buttons) * sizeof(XkbAction)); + } + memcpy(&event.buttons.names, master->button->labels, maxbuttons * sizeof(Atom)); |