summaryrefslogtreecommitdiff
path: root/lib/libXi/src/XIPassiveGrab.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2014-05-09 19:55:34 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2014-05-09 19:55:34 +0000
commita85e097bc006d743f42b66432c5c01c546f4535d (patch)
tree8716fdd25e1159d870f4efeb3500464abf850b3d /lib/libXi/src/XIPassiveGrab.c
parenta9b527ed7d121be5316628e241fe638512136635 (diff)
Update to libXi 1.7.2.
Tested by ajacoutot@ against gnome.
Diffstat (limited to 'lib/libXi/src/XIPassiveGrab.c')
-rw-r--r--lib/libXi/src/XIPassiveGrab.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libXi/src/XIPassiveGrab.c b/lib/libXi/src/XIPassiveGrab.c
index 53b4084bc..baadccb1f 100644
--- a/lib/libXi/src/XIPassiveGrab.c
+++ b/lib/libXi/src/XIPassiveGrab.c
@@ -30,6 +30,7 @@
#include <X11/extensions/XI2proto.h>
#include <X11/extensions/XInput2.h>
#include <X11/extensions/extutil.h>
+#include <limits.h>
#include "XIint.h"
static int
@@ -51,6 +52,14 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1)
return -1;
+ if (mask->mask_len > INT_MAX - 3 ||
+ (mask->mask_len + 3)/4 >= 0xffff)
+ return -1;
+
+ buff = calloc(4, (mask->mask_len + 3)/4);
+ if (!buff)
+ return -1;
+
GetReq(XIPassiveGrabDevice, req);
req->reqType = extinfo->codes->major_opcode;
req->ReqType = X_XIPassiveGrabDevice;
@@ -68,7 +77,6 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
len = req->mask_len + num_modifiers;
SetReqLen(req, len, len);
- buff = calloc(4, req->mask_len);
memcpy(buff, mask->mask, mask->mask_len);
Data(dpy, buff, req->mask_len * 4);
for (i = 0; i < num_modifiers; i++)