diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-05-03 23:10:47 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-05-03 23:25:57 -0700 |
commit | f34f6f64698c3b957aadba7315bb13726e3d79b0 (patch) | |
tree | 2ae9ee3a0cb4488556c59317ec3d9325e517a161 /src | |
parent | 9f470c92bc2d194c8abb9154f42864e6c82f43ef (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')
-rw-r--r-- | src/dmx.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -38,12 +38,16 @@ * can be included in client applications by linking with the libdmx.a * library. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include <X11/Xlibint.h> #include <X11/extensions/Xext.h> #define EXTENSION_PROC_ARGS void * #include <X11/extensions/extutil.h> #include <X11/extensions/dmxproto.h> #include <X11/extensions/dmxext.h> +#include <limits.h> static XExtensionInfo dmx_extension_info_data; static XExtensionInfo *dmx_extension_info = &dmx_extension_info_data; @@ -82,6 +86,19 @@ static XEXT_GENERATE_FIND_DISPLAY(find_display, dmx_extension_info, static XEXT_GENERATE_CLOSE_DISPLAY(close_display, dmx_extension_info) +#ifndef HAVE__XEATDATAWORDS +#include <X11/Xmd.h> /* for LONG64 on 64-bit platforms */ + +static inline void _XEatDataWords(Display *dpy, unsigned long n) +{ +# ifndef LONG64 + if (n >= (ULONG_MAX >> 2)) + _XIOError(dpy); +# endif + _XEatData (dpy, n << 2); +} +#endif + /***************************************************************************** * * |