Module Name: xsrc Committed By: msaitoh Date: Sun Apr 19 07:29:15 UTC 2015
Modified Files: xsrc/external/mit/libX11/dist/include/X11 [netbsd-5-1]: Xlibint.h xsrc/xfree/xc/lib/X11 [netbsd-5-1]: Xlibint.h Log Message: Pull up following revision(s) (requested by mrg in ticket #1959): xsrc/external/mit/libX11/dist/include/X11/Xlibint.h patch xsrc/xfree/xc/lib/X11/Xlibint.h 1.2 Fix CVE-2013-7439: Buffer overflow in MakeBigReq macro in libX11. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1.2.1 -r1.1.1.1.2.1.2.1 \ xsrc/external/mit/libX11/dist/include/X11/Xlibint.h cvs rdiff -u -r1.1.1.7 -r1.1.1.7.12.1 xsrc/xfree/xc/lib/X11/Xlibint.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: xsrc/external/mit/libX11/dist/include/X11/Xlibint.h diff -u xsrc/external/mit/libX11/dist/include/X11/Xlibint.h:1.1.1.1.2.1 xsrc/external/mit/libX11/dist/include/X11/Xlibint.h:1.1.1.1.2.1.2.1 --- xsrc/external/mit/libX11/dist/include/X11/Xlibint.h:1.1.1.1.2.1 Thu Sep 17 03:32:56 2009 +++ xsrc/external/mit/libX11/dist/include/X11/Xlibint.h Sun Apr 19 07:29:15 2015 @@ -530,6 +530,14 @@ extern LockInfoPtr _Xglobal_lock; #endif #ifdef WORD64 +/* + * MakeBigReq sets the CARD16 "req->length" to 0 and inserts a new CARD32 + * length, after req->length, before the data in the request. The new length + * includes the "n" extra 32-bit words. + * + * Do not use MakeBigReq if there is no data already in the request. + * req->length must already be >= 2. + */ #define MakeBigReq(req,n) \ { \ char _BRdat[4]; \ @@ -548,7 +556,7 @@ extern LockInfoPtr _Xglobal_lock; CARD32 _BRlen = req->length - 1; \ req->length = 0; \ _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ + memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \ ((CARD32 *)req)[1] = _BRlen + n + 2; \ Data32(dpy, &_BRdat, 4); \ } @@ -559,13 +567,20 @@ extern LockInfoPtr _Xglobal_lock; CARD32 _BRlen = req->length - 1; \ req->length = 0; \ _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ + memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \ ((CARD32 *)req)[1] = _BRlen + n + 2; \ Data32(dpy, &_BRdat, 4); \ } #endif #endif +/* + * SetReqLen increases the count of 32-bit words in the request by "n", + * or by "badlen" if "n" is too large. + * + * Do not use SetReqLen if "req" does not already have data after the + * xReq header. req->length must already be >= 2. + */ #define SetReqLen(req,n,badlen) \ if ((req->length + n) > (unsigned)65535) { \ if (dpy->bigreq_size) { \ Index: xsrc/xfree/xc/lib/X11/Xlibint.h diff -u xsrc/xfree/xc/lib/X11/Xlibint.h:1.1.1.7 xsrc/xfree/xc/lib/X11/Xlibint.h:1.1.1.7.12.1 --- xsrc/xfree/xc/lib/X11/Xlibint.h:1.1.1.7 Fri Mar 18 13:04:29 2005 +++ xsrc/xfree/xc/lib/X11/Xlibint.h Sun Apr 19 07:29:15 2015 @@ -528,6 +528,14 @@ extern LockInfoPtr _Xglobal_lock; #endif #ifdef WORD64 +/* + * MakeBigReq sets the CARD16 "req->length" to 0 and inserts a new CARD32 + * length, after req->length, before the data in the request. The new length + * includes the "n" extra 32-bit words. + * + * Do not use MakeBigReq if there is no data already in the request. + * req->length must already be >= 2. + */ #define MakeBigReq(req,n) \ { \ char _BRdat[4]; \ @@ -546,7 +554,7 @@ extern LockInfoPtr _Xglobal_lock; CARD32 _BRlen = req->length - 1; \ req->length = 0; \ _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ + memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \ ((CARD32 *)req)[1] = _BRlen + n + 2; \ Data32(dpy, &_BRdat, 4); \ } @@ -557,13 +565,20 @@ extern LockInfoPtr _Xglobal_lock; CARD32 _BRlen = req->length - 1; \ req->length = 0; \ _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ + memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \ ((CARD32 *)req)[1] = _BRlen + n + 2; \ Data32(dpy, &_BRdat, 4); \ } #endif #endif +/* + * SetReqLen increases the count of 32-bit words in the request by "n", + * or by "badlen" if "n" is too large. + * + * Do not use SetReqLen if "req" does not already have data after the + * xReq header. req->length must already be >= 2. + */ #define SetReqLen(req,n,badlen) \ if ((req->length + n) > (unsigned)65535) { \ if (dpy->bigreq_size) { \