configure.ac | 2 +- src/XExtInt.c | 2 +- src/XGMotion.c | 2 +- src/XGetCPtr.c | 2 +- src/XGetDCtl.c | 2 +- src/XGetFCtl.c | 2 +- src/XGetKMap.c | 2 +- src/XGetMMap.c | 2 +- src/XGetProp.c | 2 +- src/XGetVers.c | 28 +++++++++++----------------- src/XIAllowEvents.c | 4 ++-- src/XIGrabDevice.c | 11 +++++++++-- src/XIHierarchy.c | 16 ++++++++++------ src/XIProperties.c | 3 ++- src/XIQueryDevice.c | 3 ++- src/XIQueryVersion.c | 8 ++++++-- src/XISelEv.c | 7 +++++-- src/XIint.h | 1 - src/XListDProp.c | 2 +- src/XOpenDev.c | 2 +- src/XQueryDv.c | 2 +- 21 files changed, 59 insertions(+), 46 deletions(-)
New commits: commit f180dff710dc54d00e0e26b84de053151f8f207e Author: Peter Hutterer <peter.hutte...@who-t.net> Date: Thu Sep 10 01:16:19 2015 +1000 libXi 1.7.5 Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/configure.ac b/configure.ac index db70cef..9b40c4d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([libXi], [1.7.4], +AC_INIT([libXi], [1.7.5], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXi]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([src/config.h]) commit 05c86e53c0bae30e58b32b94e191c8720990918a Author: Cosimo Cecchi <cosi...@gnome.org> Date: Tue Feb 24 07:49:34 2015 +1000 Fix version check in _XIAllowEvents Commit 5810d0797160a97012664ffe719a59e1b288a525 changed _XIAllowEvents() to use _XiCheckVersion() instead of _XiCheckExtInit() to avoid a double display unlock, but it failed to correctly check for the version, since we should set have_XI22 to True for every version greater or equal to 2.2. Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/src/XIAllowEvents.c b/src/XIAllowEvents.c index 52c17ab..e7be099 100644 --- a/src/XIAllowEvents.c +++ b/src/XIAllowEvents.c @@ -50,7 +50,7 @@ _XIAllowEvents(Display *dpy, int deviceid, int event_mode, Time time, if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1) return (NoSuchExtension); - if (_XiCheckVersion(extinfo, XInput_2_2) == 0) + if (_XiCheckVersion(extinfo, XInput_2_2) >= 0) have_XI22 = True; if (have_XI22) commit c648441036cf5ffc5225cd484e2c906d374f0a4b Author: Michal Srb <m...@suse.com> Date: Mon Nov 3 12:43:40 2014 +0200 XIGrabDevice: Unlock display in error path. Signed-off-by: Michal Srb <m...@suse.com> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/src/XIGrabDevice.c b/src/XIGrabDevice.c index a8c5697..22f4ea1 100644 --- a/src/XIGrabDevice.c +++ b/src/XIGrabDevice.c @@ -53,14 +53,20 @@ XIGrabDevice(Display* dpy, int deviceid, Window grab_window, Time time, if (mask->mask_len > INT_MAX - 3 || (mask->mask_len + 3)/4 >= 0xffff) - return BadValue; + { + reply.status = BadValue; + goto out; + } /* mask->mask_len is in bytes, but we need 4-byte units on the wire, * and they need to be padded with 0 */ len = (mask->mask_len + 3)/4; buff = calloc(4, len); if (!buff) - return BadAlloc; + { + reply.status = BadAlloc; + goto out; + } GetReq(XIGrabDevice, req); req->reqType = extinfo->codes->major_opcode; @@ -83,6 +89,7 @@ XIGrabDevice(Display* dpy, int deviceid, Window grab_window, Time time, if (_XReply(dpy, (xReply *)&reply, 0, xTrue) == 0) reply.status = GrabSuccess; +out: UnlockDisplay(dpy); SyncHandle(); commit 29c77457ad86966ae2204b865fb8b437269063c4 Author: Michal Srb <m...@suse.com> Date: Sat Nov 1 20:00:57 2014 +0200 Refactor XGetExtensionVersion. _XiGetExtensionVersion was called from XGetExtensionVersion and from _XiCheckExtInit. When called from _XiCheckExtInit, nothing accounted for the fact that it can return ((XExtensionVersion *) NoSuchExtension) in case of error. Also it recursively calls _XiCheckExtInit potentionally causing multiple unlocks if _XiCheckExtInit fails. -> Remove it and call directly _XiGetExtensionVersionRequest and only call _XiCheckExtInit only from XGetExtensionVersion. Signed-off-by: Michal Srb <m...@suse.com> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/src/XExtInt.c b/src/XExtInt.c index d3c6b7c..672d69a 100644 --- a/src/XExtInt.c +++ b/src/XExtInt.c @@ -380,7 +380,7 @@ _XiCheckExtInit( return (-1); } ((XInputData *) info->data)->vers = - _XiGetExtensionVersion(dpy, "XInputExtension", info); + _XiGetExtensionVersionRequest(dpy, "XInputExtension", info->codes->major_opcode); } if (_XiCheckVersion(info, version_index) < 0) { diff --git a/src/XGetVers.c b/src/XGetVers.c index 0751b98..f7e22e6 100644 --- a/src/XGetVers.c +++ b/src/XGetVers.c @@ -68,12 +68,16 @@ XGetExtensionVersion(register Display * dpy, _Xconst char *name) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - ext = _XiGetExtensionVersion(dpy, name, info); - if (ext != (XExtensionVersion *) NoSuchExtension) { - UnlockDisplay(dpy); - SyncHandle(); - } - return (ext); + + if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) + return NULL; + + ext = _XiGetExtensionVersionRequest(dpy, name, info->codes->major_opcode); + + UnlockDisplay(dpy); + SyncHandle(); + + return ext; } _X_HIDDEN XExtensionVersion* @@ -91,7 +95,7 @@ _XiGetExtensionVersionRequest(Display *dpy, _Xconst char *name, int xi_opcode) _XSend(dpy, name, (long)req->nbytes); if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { - return (XExtensionVersion *) NULL; + return NULL; } ext = (XExtensionVersion *) Xmalloc(sizeof(XExtensionVersion)); @@ -105,13 +109,3 @@ _XiGetExtensionVersionRequest(Display *dpy, _Xconst char *name, int xi_opcode) return ext; } - -_X_HIDDEN XExtensionVersion * -_XiGetExtensionVersion(register Display * dpy, _Xconst char *name, - XExtDisplayInfo *info) -{ - if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) - return ((XExtensionVersion *) NoSuchExtension); - - return _XiGetExtensionVersionRequest(dpy, name, info->codes->major_opcode); -} diff --git a/src/XIint.h b/src/XIint.h index 99f3652..9479a79 100644 --- a/src/XIint.h +++ b/src/XIint.h @@ -29,7 +29,6 @@ extern XExtDisplayInfo *XInput_find_display(Display *); extern int _XiCheckExtInit(Display *, int, XExtDisplayInfo *); extern int _XiCheckVersion(XExtDisplayInfo *info, int version_index); -extern XExtensionVersion *_XiGetExtensionVersion(Display *, _Xconst char *, XExtDisplayInfo *); extern XExtensionVersion* _XiGetExtensionVersionRequest(Display *dpy, _Xconst char *name, int xi_opcode); extern Status _xiQueryVersion(Display *dpy, int*, int*, XExtDisplayInfo *); commit 5810d0797160a97012664ffe719a59e1b288a525 Author: Michal Srb <m...@suse.com> Date: Sat Nov 1 20:00:56 2014 +0200 Fix logic in _XIAllowEvents and prevent double unlock. Replacing the second _XiCheckExtInit with _XiCheckVersion prevents possible double unlock as _XiCheckExtInit actually unlocks the display when it returns -1. Signed-off-by: Michal Srb <m...@suse.com> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/src/XIAllowEvents.c b/src/XIAllowEvents.c index 2468fce..52c17ab 100644 --- a/src/XIAllowEvents.c +++ b/src/XIAllowEvents.c @@ -40,7 +40,7 @@ static Status _XIAllowEvents(Display *dpy, int deviceid, int event_mode, Time time, unsigned int touchid, Window grab_window) { - Bool have_XI22 = True; + Bool have_XI22 = False; xXIAllowEventsReq *req; xXI2_2AllowEventsReq *req_XI22; @@ -50,7 +50,7 @@ _XIAllowEvents(Display *dpy, int deviceid, int event_mode, Time time, if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1) return (NoSuchExtension); - if (_XiCheckExtInit(dpy, XInput_2_2, extinfo) == 0) + if (_XiCheckVersion(extinfo, XInput_2_2) == 0) have_XI22 = True; if (have_XI22) commit f699770e7c92da1dbf16892fde83438f0b79c979 Author: Michal Srb <m...@suse.com> Date: Sat Nov 1 20:00:54 2014 +0200 XIGetClientPointer: Return False on error. Not NoSuchExtension which is 1 = True! Signed-off-by: Michal Srb <m...@suse.com> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/src/XGetCPtr.c b/src/XGetCPtr.c index a6a44b7..59a27d3 100644 --- a/src/XGetCPtr.c +++ b/src/XGetCPtr.c @@ -49,7 +49,7 @@ XIGetClientPointer(Display* dpy, Window win, int *deviceid) LockDisplay(dpy); if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) - return (NoSuchExtension); + return False; GetReq(XIGetClientPointer, req); req->reqType = info->codes->major_opcode; commit dc1f8c6ec1ba8135afa185c8e8360c1ed90bf96c Author: Michal Srb <m...@suse.com> Date: Sat Nov 1 20:00:53 2014 +0200 Do not return NoSuchExtension casted to pointer as an error. Several functions were returning NoSuchExtension casted to a pointer in case of an error. Often in parallel with returning NULL in case of another error. It is undocumented and certainly wrong. Signed-off-by: Michal Srb <m...@suse.com> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/src/XGMotion.c b/src/XGMotion.c index a4c75b6..7785843 100644 --- a/src/XGMotion.c +++ b/src/XGMotion.c @@ -81,7 +81,7 @@ XGetDeviceMotionEvents( LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) - return ((XDeviceTimeCoord *) NoSuchExtension); + return NULL; GetReq(GetDeviceMotionEvents, req); req->reqType = info->codes->major_opcode; diff --git a/src/XGetDCtl.c b/src/XGetDCtl.c index b576aa5..c5d3b53 100644 --- a/src/XGetDCtl.c +++ b/src/XGetDCtl.c @@ -79,7 +79,7 @@ XGetDeviceControl( LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Add_XChangeDeviceControl, info) == -1) - return ((XDeviceControl *) NoSuchExtension); + return NULL; GetReq(GetDeviceControl, req); req->reqType = info->codes->major_opcode; diff --git a/src/XGetFCtl.c b/src/XGetFCtl.c index 2d71fab..7fd6d0e 100644 --- a/src/XGetFCtl.c +++ b/src/XGetFCtl.c @@ -79,7 +79,7 @@ XGetFeedbackControl( LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) - return ((XFeedbackState *) NoSuchExtension); + return NULL; GetReq(GetFeedbackControl, req); req->reqType = info->codes->major_opcode; diff --git a/src/XGetKMap.c b/src/XGetKMap.c index 00dde06..0540ce4 100644 --- a/src/XGetKMap.c +++ b/src/XGetKMap.c @@ -78,7 +78,7 @@ XGetDeviceKeyMapping(register Display * dpy, XDevice * dev, LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) - return ((KeySym *) NoSuchExtension); + return NULL; GetReq(GetDeviceKeyMapping, req); req->reqType = info->codes->major_opcode; diff --git a/src/XGetMMap.c b/src/XGetMMap.c index ce10c2d..246698c 100644 --- a/src/XGetMMap.c +++ b/src/XGetMMap.c @@ -73,7 +73,7 @@ XGetDeviceModifierMapping( LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) - return ((XModifierKeymap *) NoSuchExtension); + return NULL; GetReq(GetDeviceModifierMapping, req); req->reqType = info->codes->major_opcode; diff --git a/src/XGetProp.c b/src/XGetProp.c index 8c69ef2..a3fa558 100644 --- a/src/XGetProp.c +++ b/src/XGetProp.c @@ -75,7 +75,7 @@ XGetDeviceDontPropagateList( LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) - return ((XEventClass *) NoSuchExtension); + return NULL; GetReq(GetDeviceDontPropagateList, req); req->reqType = info->codes->major_opcode; diff --git a/src/XOpenDev.c b/src/XOpenDev.c index e784f8b..029dec2 100644 --- a/src/XOpenDev.c +++ b/src/XOpenDev.c @@ -73,7 +73,7 @@ XOpenDevice( LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) - return ((XDevice *) NoSuchExtension); + return NULL; GetReq(OpenDevice, req); req->reqType = info->codes->major_opcode; diff --git a/src/XQueryDv.c b/src/XQueryDv.c index 3836777..de1c0e5 100644 --- a/src/XQueryDv.c +++ b/src/XQueryDv.c @@ -78,7 +78,7 @@ XQueryDeviceState( LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) - return ((XDeviceState *) NoSuchExtension); + return NULL; GetReq(QueryDeviceState, req); req->reqType = info->codes->major_opcode; commit 83261c52a17543437882e2863b7f06a92c9039f8 Author: Michal Srb <m...@suse.com> Date: Sat Nov 1 20:00:52 2014 +0200 XIChangeHierarchy: Add missing unlock. When num_changes <= 0 or Xmalloc fails, the display has to be unlocked. Signed-off-by: Michal Srb <m...@suse.com> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/src/XIHierarchy.c b/src/XIHierarchy.c index 3d2b4f2..441fec0 100644 --- a/src/XIHierarchy.c +++ b/src/XIHierarchy.c @@ -49,14 +49,14 @@ XIChangeHierarchy(Display* dpy, xXIChangeHierarchyReq *req; XExtDisplayInfo *info = XInput_find_display(dpy); char *data = NULL, *dptr; - int dlen = 0, i; + int dlen = 0, i, ret = Success; LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1) return (NoSuchExtension); if (num_changes <= 0) - return Success; + goto out; GetReq(XIChangeHierarchy, req); req->reqType = info->codes->major_opcode; @@ -91,8 +91,10 @@ XIChangeHierarchy(Display* dpy, req->length += dlen / 4; /* dlen is 4-byte aligned */ data = Xmalloc(dlen); - if (!data) - return BadAlloc; + if (!data) { + ret = BadAlloc; + goto out; + } dptr = data; for (i = 0, any = changes; i < num_changes; i++, any++) @@ -155,8 +157,10 @@ XIChangeHierarchy(Display* dpy, } Data(dpy, data, dlen); + +out: Xfree(data); UnlockDisplay(dpy); SyncHandle(); - return Success; + return ret; } commit 22ae8d4f26e92b17e1ce8239a38481933d6f1ca7 Author: Michal Srb <m...@suse.com> Date: Sat Nov 1 20:00:51 2014 +0200 Fix double unlock when _XiCheckExtInit return -1. _XiCheckExtInit unlocks the display if it fails and returns -1. Most callers account for it properly, but few didn't. Signed-off-by: Michal Srb <m...@suse.com> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/src/XIProperties.c b/src/XIProperties.c index 32436d1..a16e182 100644 --- a/src/XIProperties.c +++ b/src/XIProperties.c @@ -51,7 +51,7 @@ XIListProperties(Display* dpy, int deviceid, int *num_props_return) LockDisplay(dpy); *num_props_return = 0; if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1) - goto cleanup; + goto cleanup_unlocked; GetReq(XIListProperties, req); req->reqType = info->codes->major_opcode; @@ -76,6 +76,7 @@ XIListProperties(Display* dpy, int deviceid, int *num_props_return) cleanup: UnlockDisplay(dpy); +cleanup_unlocked: SyncHandle(); return props; } diff --git a/src/XIQueryDevice.c b/src/XIQueryDevice.c index 4be1eca..fb8504f 100644 --- a/src/XIQueryDevice.c +++ b/src/XIQueryDevice.c @@ -50,7 +50,7 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return) LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1) - goto error; + goto error_unlocked; GetReq(XIQueryDevice, req); req->reqType = extinfo->codes->major_opcode; @@ -105,6 +105,7 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return) error: UnlockDisplay(dpy); +error_unlocked: SyncHandle(); *ndevices_return = -1; return NULL; diff --git a/src/XIQueryVersion.c b/src/XIQueryVersion.c index 3f2e73e..57bd079 100644 --- a/src/XIQueryVersion.c +++ b/src/XIQueryVersion.c @@ -41,10 +41,8 @@ XIQueryVersion(Display *dpy, int *major_inout, int *minor_inout) XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay(dpy); rc = _xiQueryVersion(dpy, major_inout, minor_inout, info); - UnlockDisplay(dpy); SyncHandle(); return rc; } @@ -55,6 +53,8 @@ _xiQueryVersion(Display * dpy, int *major, int *minor, XExtDisplayInfo *info) xXIQueryVersionReq *req; xXIQueryVersionReply rep; + LockDisplay(dpy); + /* This could mean either a malloc problem, or supported version < XInput_2_0 */ if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1) @@ -82,9 +82,13 @@ _xiQueryVersion(Display * dpy, int *major, int *minor, XExtDisplayInfo *info) req->minor_version = *minor; if (!_XReply(dpy, (xReply*)&rep, 0, xTrue)) { + UnlockDisplay(dpy); return BadImplementation; } + *major = rep.major_version; *minor = rep.minor_version; + + UnlockDisplay(dpy); return Success; } diff --git a/src/XISelEv.c b/src/XISelEv.c index 55c0a6a..aeee1e3 100644 --- a/src/XISelEv.c +++ b/src/XISelEv.c @@ -60,7 +60,7 @@ XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks) LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1) { r = NoSuchExtension; - goto out; + goto out_unlocked; } for (i = 0; i < num_masks; i++) { @@ -114,6 +114,7 @@ XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks) free(buff); out: UnlockDisplay(dpy); +out_unlocked: SyncHandle(); return r; @@ -134,7 +135,7 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return) *num_masks_return = -1; LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1) - goto out; + goto out_unlocked; GetReq(XIGetSelectedEvents, req); @@ -209,6 +210,8 @@ out: Xfree(mask_in); UnlockDisplay(dpy); + +out_unlocked: SyncHandle(); return mask_out; diff --git a/src/XListDProp.c b/src/XListDProp.c index bde6cb5..55f3c51 100644 --- a/src/XListDProp.c +++ b/src/XListDProp.c @@ -51,7 +51,7 @@ XListDeviceProperties(Display* dpy, XDevice* dev, int *nprops_return) LockDisplay(dpy); *nprops_return = 0; if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) - goto cleanup; + return NULL; GetReq(ListDeviceProperties, req); req->reqType = info->codes->major_opcode; commit 71a42145b678be623e30bd5bf55833a04f14376f Author: Julien Cristau <jcris...@debian.org> Date: Mon Oct 27 19:00:36 2014 +0100 Advance the request buffer by the right amount in XIChangeHierarchy c->length is in 4-byte units, dptr is a char *, so we need to advance dptr by 4 * length to get the position of the next HierarchyChangeInfo. Reviewed-by: Peter Hutterer <peter.hutte...@who-t.net> Signed-off-by: Julien Cristau <jcris...@debian.org> diff --git a/src/XIHierarchy.c b/src/XIHierarchy.c index 39c3d1b..3d2b4f2 100644 --- a/src/XIHierarchy.c +++ b/src/XIHierarchy.c @@ -109,7 +109,7 @@ XIChangeHierarchy(Display* dpy, c->name_len = strlen(C->name); c->length = (sizeof(xXIAddMasterInfo) + c->name_len + 3)/4; strncpy((char*)&c[1], C->name, c->name_len); - dptr += c->length; + dptr += 4 * c->length; } break; case XIRemoveMaster: