summaryrefslogtreecommitdiff
path: root/src/XpExtUtil.h
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-05-03 22:30:36 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-05-03 22:36:48 -0700
commit15ec6d1d0bb8c4cb24a190ed34e63312a0623670 (patch)
tree1043f65a8d3bf9ddcac13053ca1277d97d6a0a8e /src/XpExtUtil.h
parent41aab7d289aba2aaf3839e96d0c9e2f15ede4bd1 (diff)
Use _XEatDataWords to avoid overflow of rep.length bit shifting
rep.length is a CARD32, so rep.length << 2 could overflow in 32-bit builds Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src/XpExtUtil.h')
-rw-r--r--src/XpExtUtil.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/XpExtUtil.h b/src/XpExtUtil.h
index d479a95..1889825 100644
--- a/src/XpExtUtil.h
+++ b/src/XpExtUtil.h
@@ -48,6 +48,20 @@ extern char *_xpstrdup(
const char * /* str */
);
+#ifndef HAVE__XEATDATAWORDS
+#include <X11/Xmd.h> /* for LONG64 on 64-bit platforms */
+#include <limits.h>
+
+static inline void _XEatDataWords(Display *dpy, unsigned long n)
+{
+# ifndef LONG64
+ if (n >= (ULONG_MAX >> 2))
+ _XIOError(dpy);
+# endif
+ _XEatData (dpy, n << 2);
+}
+#endif
+
_XFUNCPROTOEND
#endif /* _XPEXTUTIL_H */