Module Name: xsrc Committed By: msaitoh Date: Sun Apr 19 05:56:13 UTC 2015
Modified Files: xsrc/external/mit/libX11/dist/include/X11 [netbsd-6-0]: Xlibint.h xsrc/xfree/xc/lib/X11 [netbsd-6-0]: Xlibint.h Log Message: Pull up following revision(s) (requested by mrg in ticket #1290): 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.7 -r1.1.1.7.4.1 \ xsrc/external/mit/libX11/dist/include/X11/Xlibint.h cvs rdiff -u -r1.1.1.7 -r1.1.1.7.16.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.7 xsrc/external/mit/libX11/dist/include/X11/Xlibint.h:1.1.1.7.4.1 --- xsrc/external/mit/libX11/dist/include/X11/Xlibint.h:1.1.1.7 Wed Aug 3 03:01:44 2011 +++ xsrc/external/mit/libX11/dist/include/X11/Xlibint.h Sun Apr 19 05:56:13 2015 @@ -536,6 +536,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]; \ @@ -554,7 +562,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); \ } @@ -565,13 +573,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. + */ #ifndef __clang_analyzer__ #define SetReqLen(req,n,badlen) \ if ((req->length + n) > (unsigned)65535) { \ 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.16.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 05:56:13 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) { \