diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2023-11-28 15:19:04 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2023-12-13 10:44:49 +1000 |
commit | 0c1a93d319558fe3ab2d94f51d174b4f93810afd (patch) | |
tree | ece996df4ccbd99d8e6ef2d0e2fec0a468d921b4 /Xi | |
parent | 14f480010a93ff962fef66a16412fafff81ad632 (diff) |
Xi: allocate enough XkbActions for our buttons
button->xkb_acts is supposed to be an array sufficiently large for all
our buttons, not just a single XkbActions struct. Allocating
insufficient memory here means when we memcpy() later in
XkbSetDeviceInfo we write into memory that wasn't ours to begin with,
leading to the usual security ooopsiedaisies.
CVE-2023-6377, ZDI-CAN-22412, ZDI-CAN-22413
This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/exevents.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index dcd4efb3b..54ea11a93 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -611,13 +611,13 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) } if (from->button->xkb_acts) { - if (!to->button->xkb_acts) { - to->button->xkb_acts = calloc(1, sizeof(XkbAction)); - if (!to->button->xkb_acts) - FatalError("[Xi] not enough memory for xkb_acts.\n"); - } + size_t maxbuttons = max(to->button->numButtons, from->button->numButtons); + to->button->xkb_acts = xnfreallocarray(to->button->xkb_acts, + maxbuttons, + sizeof(XkbAction)); + memset(to->button->xkb_acts, 0, maxbuttons * sizeof(XkbAction)); memcpy(to->button->xkb_acts, from->button->xkb_acts, - sizeof(XkbAction)); + from->button->numButtons * sizeof(XkbAction)); } else { free(to->button->xkb_acts); |