Sun Mar 16 22:27:36 2014 UTC ()
merge libSM 1.2.2, libXaw 1.0.12, libXfont 1.4.7, libXi 1.7.2,
libXmu 1.1.2, and libXpm 3.5.11 parts.


(mrg)
diff -r1.3 -r1.4 xsrc/external/mit/libXfont/dist/src/FreeType/ftfuncs.c
diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XGMotion.c
diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XGetDCtl.c
diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XGetDProp.c
diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XGetProp.c
diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XIPassiveGrab.c
diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XIProperties.c
diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XISelEv.c
diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XListDev.c
diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XQueryDv.c
diff -r1.3 -r1.4 xsrc/external/mit/libXi/dist/src/XGetFCtl.c

cvs diff -r1.3 -r1.4 xsrc/external/mit/libXfont/dist/src/FreeType/ftfuncs.c (expand / switch to unified diff)

--- xsrc/external/mit/libXfont/dist/src/FreeType/ftfuncs.c 2013/05/31 01:18:45 1.3
+++ xsrc/external/mit/libXfont/dist/src/FreeType/ftfuncs.c 2014/03/16 22:27:35 1.4
@@ -2040,27 +2040,27 @@ restrict_code_range(unsigned short *refF @@ -2040,27 +2040,27 @@ restrict_code_range(unsigned short *refF
2040 } 2040 }
2041} 2041}
2042 2042
2043 2043
2044static int 2044static int
2045restrict_code_range_by_str(int count,unsigned short *refFirstCol, 2045restrict_code_range_by_str(int count,unsigned short *refFirstCol,
2046 unsigned short *refFirstRow, 2046 unsigned short *refFirstRow,
2047 unsigned short *refLastCol, 2047 unsigned short *refLastCol,
2048 unsigned short *refLastRow, 2048 unsigned short *refLastRow,
2049 char const *str) 2049 char const *str)
2050{ 2050{
2051 int nRanges = 0; 2051 int nRanges = 0;
2052 int result = 0; 2052 int result = 0;
2053 fsRange *ranges = NULL; 2053 fsRange *ranges = NULL, *oldRanges;
2054 char const *p, *q; 2054 char const *p, *q;
2055 2055
2056 p = q = str; 2056 p = q = str;
2057 for (;;) { 2057 for (;;) {
2058 int minpoint=0, maxpoint=65535; 2058 int minpoint=0, maxpoint=65535;
2059 long val; 2059 long val;
2060 2060
2061 /* skip comma and/or space */ 2061 /* skip comma and/or space */
2062 while (',' == *p || isspace(*p)) 2062 while (',' == *p || isspace(*p))
2063 p++; 2063 p++;
2064 2064
2065 /* begin point */ 2065 /* begin point */
2066 if ('-' != *p) { 2066 if ('-' != *p) {
@@ -2109,30 +2109,33 @@ restrict_code_range_by_str(int count,uns @@ -2109,30 +2109,33 @@ restrict_code_range_by_str(int count,uns
2109 if ( count <= 0 && minpoint>maxpoint ) { 2109 if ( count <= 0 && minpoint>maxpoint ) {
2110 int tmp; 2110 int tmp;
2111 tmp = minpoint; 2111 tmp = minpoint;
2112 minpoint = maxpoint; 2112 minpoint = maxpoint;
2113 maxpoint = tmp; 2113 maxpoint = tmp;
2114 } 2114 }
2115 2115
2116 /* add range */ 2116 /* add range */
2117#if 0 2117#if 0
2118 fprintf(stderr, "zone: 0x%04X - 0x%04X\n", minpoint, maxpoint); 2118 fprintf(stderr, "zone: 0x%04X - 0x%04X\n", minpoint, maxpoint);
2119 fflush(stderr); 2119 fflush(stderr);
2120#endif 2120#endif
2121 nRanges++; 2121 nRanges++;
 2122 oldRanges = ranges;
2122 ranges = realloc(ranges, nRanges*sizeof(*ranges)); 2123 ranges = realloc(ranges, nRanges*sizeof(*ranges));
2123 if (NULL == ranges) 2124 if (NULL == ranges) {
 2125 free(oldRanges);
2124 break; 2126 break;
2125 { 2127 }
 2128 else {
2126 fsRange *r = ranges+nRanges-1; 2129 fsRange *r = ranges+nRanges-1;
2127 2130
2128 r->min_char_low = minpoint & 0xff; 2131 r->min_char_low = minpoint & 0xff;
2129 r->max_char_low = maxpoint & 0xff; 2132 r->max_char_low = maxpoint & 0xff;
2130 r->min_char_high = (minpoint>>8) & 0xff; 2133 r->min_char_high = (minpoint>>8) & 0xff;
2131 r->max_char_high = (maxpoint>>8) & 0xff; 2134 r->max_char_high = (maxpoint>>8) & 0xff;
2132 } 2135 }
2133 } 2136 }
2134 2137
2135 if (ranges) { 2138 if (ranges) {
2136 if ( count <= 0 ) { 2139 if ( count <= 0 ) {
2137 restrict_code_range(refFirstCol, refFirstRow, refLastCol, refLastRow, 2140 restrict_code_range(refFirstCol, refFirstRow, refLastCol, refLastRow,
2138 ranges, nRanges); 2141 ranges, nRanges);
@@ -2194,27 +2197,27 @@ FreeTypeSetUpTTCap( char *fileName, Font @@ -2194,27 +2197,27 @@ FreeTypeSetUpTTCap( char *fileName, Font
2194 int dirLen = p1-fileName; 2197 int dirLen = p1-fileName;
2195 int baseLen = fileName+len - p2 -1; 2198 int baseLen = fileName+len - p2 -1;
2196 2199
2197 *dynStrRealFileName = malloc(dirLen+baseLen+1); 2200 *dynStrRealFileName = malloc(dirLen+baseLen+1);
2198 if( *dynStrRealFileName == NULL ) { 2201 if( *dynStrRealFileName == NULL ) {
2199 result = AllocError; 2202 result = AllocError;
2200 goto quit; 2203 goto quit;
2201 } 2204 }
2202 if ( 0 < dirLen ) 2205 if ( 0 < dirLen )
2203 memcpy(*dynStrRealFileName, fileName, dirLen); 2206 memcpy(*dynStrRealFileName, fileName, dirLen);
2204 strcpy(*dynStrRealFileName+dirLen, p2+1); 2207 strcpy(*dynStrRealFileName+dirLen, p2+1);
2205 capHead = p1; 2208 capHead = p1;
2206 } else { 2209 } else {
2207 *dynStrRealFileName = xstrdup(fileName); 2210 *dynStrRealFileName = strdup(fileName);
2208 if( *dynStrRealFileName == NULL ) { 2211 if( *dynStrRealFileName == NULL ) {
2209 result = AllocError; 2212 result = AllocError;
2210 goto quit; 2213 goto quit;
2211 } 2214 }
2212 } 2215 }
2213 } 2216 }
2214 2217
2215 /* font cap */ 2218 /* font cap */
2216 if (capHead) { 2219 if (capHead) {
2217 if (SPropRecValList_add_by_font_cap(&listPropRecVal, 2220 if (SPropRecValList_add_by_font_cap(&listPropRecVal,
2218 capHead)) { 2221 capHead)) {
2219 result = BadFontPath; 2222 result = BadFontPath;
2220 goto quit; 2223 goto quit;
@@ -2279,33 +2282,31 @@ FreeTypeSetUpTTCap( char *fileName, Font @@ -2279,33 +2282,31 @@ FreeTypeSetUpTTCap( char *fileName, Font
2279 strcat(*dynStrFTFileName,":"); 2282 strcat(*dynStrFTFileName,":");
2280 strcat(*dynStrFTFileName,beginptr); 2283 strcat(*dynStrFTFileName,beginptr);
2281 strcat(*dynStrFTFileName,":"); 2284 strcat(*dynStrFTFileName,":");
2282 strcat(*dynStrFTFileName,slash+1); 2285 strcat(*dynStrFTFileName,slash+1);
2283 } 2286 }
2284 else{ 2287 else{
2285 strcat(*dynStrFTFileName,":"); 2288 strcat(*dynStrFTFileName,":");
2286 strcat(*dynStrFTFileName,beginptr); 2289 strcat(*dynStrFTFileName,beginptr);
2287 strcat(*dynStrFTFileName,":"); 2290 strcat(*dynStrFTFileName,":");
2288 strcat(*dynStrFTFileName,*dynStrRealFileName); 2291 strcat(*dynStrFTFileName,*dynStrRealFileName);
2289 } 2292 }
2290 } 2293 }
2291 else{ 2294 else{
2292 *dynStrFTFileName = malloc(strlen(*dynStrRealFileName)+1); 2295 *dynStrFTFileName = strdup(*dynStrRealFileName);
2293 if( *dynStrFTFileName == NULL ){ 2296 if( *dynStrFTFileName == NULL ){
2294 result = AllocError; 2297 result = AllocError;
2295 goto quit; 2298 goto quit;
2296 } 2299 }
2297 **dynStrFTFileName = '\0'; 
2298 strcat(*dynStrFTFileName,*dynStrRealFileName); 
2299 } 2300 }
2300 } 2301 }
2301 /* 2302 /*
2302 fprintf(stderr,"[Filename:%s]\n",fileName); 2303 fprintf(stderr,"[Filename:%s]\n",fileName);
2303 fprintf(stderr,"[RealFilename:%s]\n",*dynStrRealFileName); 2304 fprintf(stderr,"[RealFilename:%s]\n",*dynStrRealFileName);
2304 fprintf(stderr,"[FTFilename:%s]\n",*dynStrFTFileName); 2305 fprintf(stderr,"[FTFilename:%s]\n",*dynStrFTFileName);
2305 */ 2306 */
2306 /* slant control */ 2307 /* slant control */
2307 if (SPropRecValList_search_record(&listPropRecVal, 2308 if (SPropRecValList_search_record(&listPropRecVal,
2308 &contRecValue, 2309 &contRecValue,
2309 "AutoItalic")) 2310 "AutoItalic"))
2310 ret->autoItalic = SPropContainer_value_dbl(contRecValue); 2311 ret->autoItalic = SPropContainer_value_dbl(contRecValue);
2311 /* hinting control */ 2312 /* hinting control */
@@ -2539,27 +2540,27 @@ FreeTypeSetUpTTCap( char *fileName, Font @@ -2539,27 +2540,27 @@ FreeTypeSetUpTTCap( char *fileName, Font
2539#if 0 2540#if 0
2540 if (scaleBitmapWidth<=0.0) { 2541 if (scaleBitmapWidth<=0.0) {
2541 fprintf(stderr, "ScaleBitmapWitdh needs plus.\n"); 2542 fprintf(stderr, "ScaleBitmapWitdh needs plus.\n");
2542 result = BadFontName; 2543 result = BadFontName;
2543 goto quit; 2544 goto quit;
2544 } 2545 }
2545#endif 2546#endif
2546 ret->scaleBitmap = scaleBitmapWidth; 2547 ret->scaleBitmap = scaleBitmapWidth;
2547 } 2548 }
2548 /* restriction of the code range */ 2549 /* restriction of the code range */
2549 if (SPropRecValList_search_record(&listPropRecVal, 2550 if (SPropRecValList_search_record(&listPropRecVal,
2550 &contRecValue, 2551 &contRecValue,
2551 "CodeRange")) { 2552 "CodeRange")) {
2552 *dynStrTTCapCodeRange = xstrdup(SPropContainer_value_str(contRecValue)); 2553 *dynStrTTCapCodeRange = strdup(SPropContainer_value_str(contRecValue));
2553 if( *dynStrTTCapCodeRange == NULL ) { 2554 if( *dynStrTTCapCodeRange == NULL ) {
2554 result = AllocError; 2555 result = AllocError;
2555 goto quit; 2556 goto quit;
2556 } 2557 }
2557 } 2558 }
2558 /* forceConstantSpacing{Begin,End} */ 2559 /* forceConstantSpacing{Begin,End} */
2559 if ( 1 /* ft->spacing == 'p' */ ){ 2560 if ( 1 /* ft->spacing == 'p' */ ){
2560 unsigned short first_col=0,last_col=0x00ff; 2561 unsigned short first_col=0,last_col=0x00ff;
2561 unsigned short first_row=0,last_row=0x00ff; 2562 unsigned short first_row=0,last_row=0x00ff;
2562 if (SPropRecValList_search_record(&listPropRecVal, 2563 if (SPropRecValList_search_record(&listPropRecVal,
2563 &contRecValue, 2564 &contRecValue,
2564 "ForceConstantSpacingCodeRange")) { 2565 "ForceConstantSpacingCodeRange")) {
2565 if ( restrict_code_range_by_str(1,&first_col, &first_row, 2566 if ( restrict_code_range_by_str(1,&first_col, &first_row,

cvs diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XGMotion.c (expand / switch to unified diff)

--- xsrc/external/mit/libXi/dist/src/XGMotion.c 2013/06/06 06:46:32 1.2
+++ xsrc/external/mit/libXi/dist/src/XGMotion.c 2014/03/16 22:27:35 1.3
@@ -114,27 +114,27 @@ XGetDeviceMotionEvents( @@ -114,27 +114,27 @@ XGetDeviceMotionEvents(
114 } 114 }
115 /* rep.axes is a CARD8, so assume max number of axes for bounds check */ 115 /* rep.axes is a CARD8, so assume max number of axes for bounds check */
116 if (rep.nEvents < 116 if (rep.nEvents <
117 (INT_MAX / (sizeof(XDeviceTimeCoord) + (UCHAR_MAX * sizeof(int))))) { 117 (INT_MAX / (sizeof(XDeviceTimeCoord) + (UCHAR_MAX * sizeof(int))))) {
118 size_t bsize = rep.nEvents * 118 size_t bsize = rep.nEvents *
119 (sizeof(XDeviceTimeCoord) + (rep.axes * sizeof(int))); 119 (sizeof(XDeviceTimeCoord) + (rep.axes * sizeof(int)));
120 bufp = Xmalloc(bsize); 120 bufp = Xmalloc(bsize);
121 } else 121 } else
122 bufp = NULL; 122 bufp = NULL;
123 if (!bufp || !savp) { 123 if (!bufp || !savp) {
124 Xfree(bufp); 124 Xfree(bufp);
125 Xfree(savp); 125 Xfree(savp);
126 *nEvents = 0; 126 *nEvents = 0;
127 _XEatData(dpy, (unsigned long)size); 127 _XEatDataWords(dpy, rep.length);
128 UnlockDisplay(dpy); 128 UnlockDisplay(dpy);
129 SyncHandle(); 129 SyncHandle();
130 return (NULL); 130 return (NULL);
131 } 131 }
132 _XRead(dpy, (char *)readp, size); 132 _XRead(dpy, (char *)readp, size);
133 133
134 tc = (XDeviceTimeCoord *) bufp; 134 tc = (XDeviceTimeCoord *) bufp;
135 data = (int *)(tc + rep.nEvents); 135 data = (int *)(tc + rep.nEvents);
136 for (i = 0; i < *nEvents; i++, tc++) { 136 for (i = 0; i < *nEvents; i++, tc++) {
137 tc->time = *readp++; 137 tc->time = *readp++;
138 tc->data = data; 138 tc->data = data;
139 for (j = 0; j < *axis_count; j++) 139 for (j = 0; j < *axis_count; j++)
140 *data++ = *readp++; 140 *data++ = *readp++;

cvs diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XGetDCtl.c (expand / switch to unified diff)

--- xsrc/external/mit/libXi/dist/src/XGetDCtl.c 2013/06/06 06:46:32 1.2
+++ xsrc/external/mit/libXi/dist/src/XGetDCtl.c 2014/03/16 22:27:35 1.3
@@ -88,78 +88,78 @@ XGetDeviceControl( @@ -88,78 +88,78 @@ XGetDeviceControl(
88 req->control = control; 88 req->control = control;
89 89
90 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) 90 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
91 goto out; 91 goto out;
92 92
93 if (rep.length > 0) { 93 if (rep.length > 0) {
94 unsigned long nbytes; 94 unsigned long nbytes;
95 size_t size = 0; 95 size_t size = 0;
96 if (rep.length < (INT_MAX >> 2)) { 96 if (rep.length < (INT_MAX >> 2)) {
97 nbytes = (unsigned long) rep.length << 2; 97 nbytes = (unsigned long) rep.length << 2;
98 d = Xmalloc(nbytes); 98 d = Xmalloc(nbytes);
99 } 99 }
100 if (!d) { 100 if (!d) {
101 _XEatData(dpy, (unsigned long)nbytes); 101 _XEatDataWords(dpy, rep.length);
102 goto out; 102 goto out;
103 } 103 }
104 sav = d; 104 sav = d;
105 _XRead(dpy, (char *)d, nbytes); 105 _XRead(dpy, (char *)d, nbytes);
106 106
107 /* In theory, we should just be able to use d->length to get the size. 107 /* In theory, we should just be able to use d->length to get the size.
108 * Turns out that a number of X servers (up to and including server 108 * Turns out that a number of X servers (up to and including server
109 * 1.4) sent the wrong length value down the wire. So to not break 109 * 1.4) sent the wrong length value down the wire. So to not break
110 * apps that run against older servers, we have to calculate the size 110 * apps that run against older servers, we have to calculate the size
111 * manually. 111 * manually.
112 */ 112 */
113 switch (d->control) { 113 switch (d->control) {
114 case DEVICE_RESOLUTION: 114 case DEVICE_RESOLUTION:
115 { 115 {
116 xDeviceResolutionState *r; 116 xDeviceResolutionState *r;
117 size_t val_size; 117 size_t val_size;
118 118
119 r = (xDeviceResolutionState *) d; 119 r = (xDeviceResolutionState *) d;
120 if (r->num_valuators >= (INT_MAX / (3 * sizeof(int)))) 120 if (r->num_valuators >= (INT_MAX / (3 * sizeof(int))))
121 goto out; 121 goto out;
122 val_size = 3 * sizeof(int) * r->num_valuators; 122 val_size = 3 * sizeof(int) * r->num_valuators;
123 if ((sizeof(xDeviceResolutionState) + val_size) > nbytes) 123 if ((sizeof(xDeviceResolutionState) + val_size) > nbytes)
124 goto out; 124 goto out;
125 size += sizeof(XDeviceResolutionState) + val_size; 125 size = sizeof(XDeviceResolutionState) + val_size;
126 break; 126 break;
127 } 127 }
128 case DEVICE_ABS_CALIB: 128 case DEVICE_ABS_CALIB:
129 { 129 {
130 if (sizeof(xDeviceAbsCalibState) > nbytes) 130 if (sizeof(xDeviceAbsCalibState) > nbytes)
131 goto out; 131 goto out;
132 size += sizeof(XDeviceAbsCalibState); 132 size = sizeof(XDeviceAbsCalibState);
133 break; 133 break;
134 } 134 }
135 case DEVICE_ABS_AREA: 135 case DEVICE_ABS_AREA:
136 { 136 {
137 if (sizeof(xDeviceAbsAreaState) > nbytes) 137 if (sizeof(xDeviceAbsAreaState) > nbytes)
138 goto out; 138 goto out;
139 size += sizeof(XDeviceAbsAreaState); 139 size = sizeof(XDeviceAbsAreaState);
140 break; 140 break;
141 } 141 }
142 case DEVICE_CORE: 142 case DEVICE_CORE:
143 { 143 {
144 if (sizeof(xDeviceCoreState) > nbytes) 144 if (sizeof(xDeviceCoreState) > nbytes)
145 goto out; 145 goto out;
146 size += sizeof(XDeviceCoreState); 146 size = sizeof(XDeviceCoreState);
147 break; 147 break;
148 } 148 }
149 default: 149 default:
150 if (d->length > nbytes) 150 if (d->length > nbytes)
151 goto out; 151 goto out;
152 size += d->length; 152 size = d->length;
153 break; 153 break;
154 } 154 }
155 155
156 Device = Xmalloc(size); 156 Device = Xmalloc(size);
157 if (!Device) 157 if (!Device)
158 goto out; 158 goto out;
159 159
160 Sav = Device; 160 Sav = Device;
161 161
162 d = sav; 162 d = sav;
163 switch (control) { 163 switch (control) {
164 case DEVICE_RESOLUTION: 164 case DEVICE_RESOLUTION:
165 { 165 {

cvs diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XGetDProp.c (expand / switch to unified diff)

--- xsrc/external/mit/libXi/dist/src/XGetDProp.c 2013/06/06 06:46:32 1.2
+++ xsrc/external/mit/libXi/dist/src/XGetDProp.c 2014/03/16 22:27:35 1.3
@@ -120,27 +120,27 @@ XGetDeviceProperty(Display* dpy, XDevice @@ -120,27 +120,27 @@ XGetDeviceProperty(Display* dpy, XDevice
120 else 120 else
121 ret = BadAlloc; 121 ret = BadAlloc;
122 } 122 }
123 break; 123 break;
124 124
125 default: 125 default:
126 /* 126 /*
127 * This part of the code should never be reached. If it is, 127 * This part of the code should never be reached. If it is,
128 * the server sent back a property with an invalid format. 128 * the server sent back a property with an invalid format.
129 */ 129 */
130 ret = BadImplementation; 130 ret = BadImplementation;
131 } 131 }
132 if (! *prop) { 132 if (! *prop) {
133 _XEatData(dpy, (unsigned long) nbytes); 133 _XEatDataWords(dpy, rep.length);
134 if (ret == Success) 134 if (ret == Success)
135 ret = BadAlloc; 135 ret = BadAlloc;
136 goto out; 136 goto out;
137 } 137 }
138 (*prop)[rbytes - 1] = '\0'; 138 (*prop)[rbytes - 1] = '\0';
139 } 139 }
140 140
141 *actual_type = rep.propertyType; 141 *actual_type = rep.propertyType;
142 *actual_format = rep.format; 142 *actual_format = rep.format;
143 *nitems = rep.nItems; 143 *nitems = rep.nItems;
144 *bytes_after = rep.bytesAfter; 144 *bytes_after = rep.bytesAfter;
145 out: 145 out:
146 UnlockDisplay (dpy); 146 UnlockDisplay (dpy);

cvs diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XGetProp.c (expand / switch to unified diff)

--- xsrc/external/mit/libXi/dist/src/XGetProp.c 2013/06/06 06:46:32 1.2
+++ xsrc/external/mit/libXi/dist/src/XGetProp.c 2014/03/16 22:27:35 1.3
@@ -59,58 +59,58 @@ SOFTWARE. @@ -59,58 +59,58 @@ SOFTWARE.
59#include <X11/Xlibint.h> 59#include <X11/Xlibint.h>
60#include <X11/extensions/XInput.h> 60#include <X11/extensions/XInput.h>
61#include <X11/extensions/extutil.h> 61#include <X11/extensions/extutil.h>
62#include "XIint.h" 62#include "XIint.h"
63#include <limits.h> 63#include <limits.h>
64 64
65XEventClass * 65XEventClass *
66XGetDeviceDontPropagateList( 66XGetDeviceDontPropagateList(
67 register Display *dpy, 67 register Display *dpy,
68 Window window, 68 Window window,
69 int *count) 69 int *count)
70{ 70{
71 XEventClass *list = NULL; 71 XEventClass *list = NULL;
72 int rlen; 
73 xGetDeviceDontPropagateListReq *req; 72 xGetDeviceDontPropagateListReq *req;
74 xGetDeviceDontPropagateListReply rep; 73 xGetDeviceDontPropagateListReply rep;
75 XExtDisplayInfo *info = XInput_find_display(dpy); 74 XExtDisplayInfo *info = XInput_find_display(dpy);
76 75
77 LockDisplay(dpy); 76 LockDisplay(dpy);
78 if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) 77 if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1)
79 return ((XEventClass *) NoSuchExtension); 78 return ((XEventClass *) NoSuchExtension);
80 79
81 GetReq(GetDeviceDontPropagateList, req); 80 GetReq(GetDeviceDontPropagateList, req);
82 req->reqType = info->codes->major_opcode; 81 req->reqType = info->codes->major_opcode;
83 req->ReqType = X_GetDeviceDontPropagateList; 82 req->ReqType = X_GetDeviceDontPropagateList;
84 req->window = window; 83 req->window = window;
85 84
86 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { 85 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
87 UnlockDisplay(dpy); 86 UnlockDisplay(dpy);
88 SyncHandle(); 87 SyncHandle();
89 return (XEventClass *) NULL; 88 return (XEventClass *) NULL;
90 } 89 }
91 *count = rep.count; 90 *count = rep.count;
92 91
93 if (rep.length != 0) { 92 if (rep.length != 0) {
94 if ((rep.count != 0) && (rep.length < (INT_MAX / sizeof(XEventClass)))) 93 if ((rep.count != 0) && (rep.length < (INT_MAX / sizeof(XEventClass))))
95 list = Xmalloc(rep.length * sizeof(XEventClass)); 94 list = Xmalloc(rep.length * sizeof(XEventClass));
96 rlen = rep.length << 2; 
97 if (list) { 95 if (list) {
98 unsigned int i; 96 unsigned int i;
99 CARD32 ec; 97 CARD32 ec;
100 98
101 /* read and assign each XEventClass separately because 99 /* read and assign each XEventClass separately because
102 * the library representation may not be the same size 100 * the library representation may not be the same size
103 * as the wire representation (64 bit machines) 101 * as the wire representation (64 bit machines)
104 */ 102 */
105 for (i = 0; i < rep.length; i++) { 103 for (i = 0; i < rep.length; i++) {
106 _XRead(dpy, (char *)(&ec), sizeof(CARD32)); 104 _XRead(dpy, (char *)(&ec), sizeof(CARD32));
107 list[i] = (XEventClass) ec; 105 list[i] = (XEventClass) ec;
108 } 106 }
109 } else 107 } else {
110 _XEatData(dpy, (unsigned long)rlen); 108 *count = 0;
 109 _XEatDataWords(dpy, rep.length);
 110 }
111 } 111 }
112 112
113 UnlockDisplay(dpy); 113 UnlockDisplay(dpy);
114 SyncHandle(); 114 SyncHandle();
115 return (list); 115 return (list);
116} 116}

cvs diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XIPassiveGrab.c (expand / switch to unified diff)

--- xsrc/external/mit/libXi/dist/src/XIPassiveGrab.c 2013/06/06 06:46:32 1.2
+++ xsrc/external/mit/libXi/dist/src/XIPassiveGrab.c 2014/03/16 22:27:35 1.3
@@ -20,65 +20,73 @@ @@ -20,65 +20,73 @@
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE. 21 * DEALINGS IN THE SOFTWARE.
22 * 22 *
23 */ 23 */
24#ifdef HAVE_CONFIG_H 24#ifdef HAVE_CONFIG_H
25#include <config.h> 25#include <config.h>
26#endif 26#endif
27 27
28#include <stdint.h> 28#include <stdint.h>
29#include <X11/Xlibint.h> 29#include <X11/Xlibint.h>
30#include <X11/extensions/XI2proto.h> 30#include <X11/extensions/XI2proto.h>
31#include <X11/extensions/XInput2.h> 31#include <X11/extensions/XInput2.h>
32#include <X11/extensions/extutil.h> 32#include <X11/extensions/extutil.h>
 33#include <limits.h>
33#include "XIint.h" 34#include "XIint.h"
34 35
35static int 36static int
36_XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail, 37_XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
37 Window grab_window, Cursor cursor, 38 Window grab_window, Cursor cursor,
38 int grab_mode, int paired_device_mode, 39 int grab_mode, int paired_device_mode,
39 Bool owner_events, XIEventMask *mask, 40 Bool owner_events, XIEventMask *mask,
40 int num_modifiers, XIGrabModifiers *modifiers_inout) 41 int num_modifiers, XIGrabModifiers *modifiers_inout)
41{ 42{
42 xXIPassiveGrabDeviceReq *req; 43 xXIPassiveGrabDeviceReq *req;
43 xXIPassiveGrabDeviceReply reply; 44 xXIPassiveGrabDeviceReply reply;
44 xXIGrabModifierInfo *failed_mods; 45 xXIGrabModifierInfo *failed_mods;
45 int len = 0, i; 46 int len = 0, i;
46 char *buff; 47 char *buff;
47 48
48 XExtDisplayInfo *extinfo = XInput_find_display(dpy); 49 XExtDisplayInfo *extinfo = XInput_find_display(dpy);
49 50
50 LockDisplay(dpy); 51 LockDisplay(dpy);
51 if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1) 52 if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1)
52 return -1; 53 return -1;
53 54
 55 if (mask->mask_len > INT_MAX - 3 ||
 56 (mask->mask_len + 3)/4 >= 0xffff)
 57 return -1;
 58
 59 buff = calloc(4, (mask->mask_len + 3)/4);
 60 if (!buff)
 61 return -1;
 62
54 GetReq(XIPassiveGrabDevice, req); 63 GetReq(XIPassiveGrabDevice, req);
55 req->reqType = extinfo->codes->major_opcode; 64 req->reqType = extinfo->codes->major_opcode;
56 req->ReqType = X_XIPassiveGrabDevice; 65 req->ReqType = X_XIPassiveGrabDevice;
57 req->deviceid = deviceid; 66 req->deviceid = deviceid;
58 req->grab_mode = grab_mode; 67 req->grab_mode = grab_mode;
59 req->paired_device_mode = paired_device_mode; 68 req->paired_device_mode = paired_device_mode;
60 req->owner_events = owner_events; 69 req->owner_events = owner_events;
61 req->grab_window = grab_window; 70 req->grab_window = grab_window;
62 req->cursor = cursor; 71 req->cursor = cursor;
63 req->detail = detail; 72 req->detail = detail;
64 req->num_modifiers = num_modifiers; 73 req->num_modifiers = num_modifiers;
65 req->mask_len = (mask->mask_len + 3)/4; 74 req->mask_len = (mask->mask_len + 3)/4;
66 req->grab_type = grabtype; 75 req->grab_type = grabtype;
67 76
68 len = req->mask_len + num_modifiers; 77 len = req->mask_len + num_modifiers;
69 SetReqLen(req, len, len); 78 SetReqLen(req, len, len);
70 79
71 buff = calloc(4, req->mask_len); 
72 memcpy(buff, mask->mask, mask->mask_len); 80 memcpy(buff, mask->mask, mask->mask_len);
73 Data(dpy, buff, req->mask_len * 4); 81 Data(dpy, buff, req->mask_len * 4);
74 for (i = 0; i < num_modifiers; i++) 82 for (i = 0; i < num_modifiers; i++)
75 Data(dpy, (char*)&modifiers_inout[i].modifiers, 4); 83 Data(dpy, (char*)&modifiers_inout[i].modifiers, 4);
76 84
77 free(buff); 85 free(buff);
78 86
79 if (!_XReply(dpy, (xReply *)&reply, 0, xFalse)) 87 if (!_XReply(dpy, (xReply *)&reply, 0, xFalse))
80 { 88 {
81 UnlockDisplay(dpy); 89 UnlockDisplay(dpy);
82 SyncHandle(); 90 SyncHandle();
83 return -1; 91 return -1;
84 } 92 }

cvs diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XIProperties.c (expand / switch to unified diff)

--- xsrc/external/mit/libXi/dist/src/XIProperties.c 2013/06/06 06:46:32 1.2
+++ xsrc/external/mit/libXi/dist/src/XIProperties.c 2014/03/16 22:27:35 1.3
@@ -55,27 +55,27 @@ XIListProperties(Display* dpy, int devic @@ -55,27 +55,27 @@ XIListProperties(Display* dpy, int devic
55 55
56 GetReq(XIListProperties, req); 56 GetReq(XIListProperties, req);
57 req->reqType = info->codes->major_opcode; 57 req->reqType = info->codes->major_opcode;
58 req->ReqType = X_XIListProperties; 58 req->ReqType = X_XIListProperties;
59 req->deviceid = deviceid; 59 req->deviceid = deviceid;
60 60
61 if (!_XReply(dpy, (xReply*)&rep, 0, xFalse)) 61 if (!_XReply(dpy, (xReply*)&rep, 0, xFalse))
62 goto cleanup; 62 goto cleanup;
63 63
64 if (rep.num_properties) { 64 if (rep.num_properties) {
65 props = (Atom*)Xmalloc(rep.num_properties * sizeof(Atom)); 65 props = (Atom*)Xmalloc(rep.num_properties * sizeof(Atom));
66 if (!props) 66 if (!props)
67 { 67 {
68 _XEatData(dpy, rep.num_properties << 2); 68 _XEatDataWords(dpy, rep.length);
69 goto cleanup; 69 goto cleanup;
70 } 70 }
71 71
72 _XRead32(dpy, (long*)props, rep.num_properties << 2); 72 _XRead32(dpy, (long*)props, rep.num_properties << 2);
73 } 73 }
74 74
75 *num_props_return = rep.num_properties; 75 *num_props_return = rep.num_properties;
76 76
77cleanup: 77cleanup:
78 UnlockDisplay(dpy); 78 UnlockDisplay(dpy);
79 SyncHandle(); 79 SyncHandle();
80 return props; 80 return props;
81} 81}
@@ -194,48 +194,47 @@ XIGetProperty(Display* dpy, int deviceid @@ -194,48 +194,47 @@ XIGetProperty(Display* dpy, int deviceid
194 UnlockDisplay (dpy); 194 UnlockDisplay (dpy);
195 SyncHandle (); 195 SyncHandle ();
196 return 1; 196 return 1;
197 } 197 }
198 198
199 *data = NULL; 199 *data = NULL;
200 200
201 if (rep.type != None) { 201 if (rep.type != None) {
202 if (rep.format != 8 && rep.format != 16 && rep.format != 32) { 202 if (rep.format != 8 && rep.format != 16 && rep.format != 32) {
203 /* 203 /*
204 * This part of the code should never be reached. If it is, 204 * This part of the code should never be reached. If it is,
205 * the server sent back a property with an invalid format. 205 * the server sent back a property with an invalid format.
206 */ 206 */
207 nbytes = rep.length << 2; 207 _XEatDataWords(dpy, rep.length);
208 _XEatData(dpy, nbytes); 
209 UnlockDisplay(dpy); 208 UnlockDisplay(dpy);
210 SyncHandle(); 209 SyncHandle();
211 return(BadImplementation); 210 return(BadImplementation);
212 } 211 }
213 212
214 /* 213 /*
215 * One extra byte is malloced than is needed to contain the property 214 * One extra byte is malloced than is needed to contain the property
216 * data, but this last byte is null terminated and convenient for 215 * data, but this last byte is null terminated and convenient for
217 * returning string properties, so the client doesn't then have to 216 * returning string properties, so the client doesn't then have to
218 * recopy the string to make it null terminated. 217 * recopy the string to make it null terminated.
219 */ 218 */
220 219
221 if (rep.num_items < (INT_MAX / (rep.format/8))) { 220 if (rep.num_items < (INT_MAX / (rep.format/8))) {
222 nbytes = rep.num_items * rep.format/8; 221 nbytes = rep.num_items * rep.format/8;
223 rbytes = nbytes + 1; 222 rbytes = nbytes + 1;
224 *data = Xmalloc(rbytes); 223 *data = Xmalloc(rbytes);
225 } 224 }
226 225
227 if (!(*data)) { 226 if (!(*data)) {
228 _XEatData(dpy, nbytes); 227 _XEatDataWords(dpy, rep.length);
229 UnlockDisplay(dpy); 228 UnlockDisplay(dpy);
230 SyncHandle(); 229 SyncHandle();
231 return(BadAlloc); 230 return(BadAlloc);
232 } 231 }
233 232
234 _XReadPad (dpy, (char *)*data, nbytes); 233 _XReadPad (dpy, (char *)*data, nbytes);
235 (*data)[rbytes - 1] = '\0'; 234 (*data)[rbytes - 1] = '\0';
236 } 235 }
237 236
238 *type_return = rep.type; 237 *type_return = rep.type;
239 *format_return = rep.format; 238 *format_return = rep.format;
240 *num_items_return = rep.num_items; 239 *num_items_return = rep.num_items;
241 *bytes_after_return = rep.bytes_after; 240 *bytes_after_return = rep.bytes_after;

cvs diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XISelEv.c (expand / switch to unified diff)

--- xsrc/external/mit/libXi/dist/src/XISelEv.c 2013/06/06 06:46:32 1.2
+++ xsrc/external/mit/libXi/dist/src/XISelEv.c 2014/03/16 22:27:35 1.3
@@ -43,65 +43,85 @@ in this Software without prior written a @@ -43,65 +43,85 @@ in this Software without prior written a
43#include <X11/extensions/geproto.h> 43#include <X11/extensions/geproto.h>
44#include "XIint.h" 44#include "XIint.h"
45#include <limits.h> 45#include <limits.h>
46 46
47int 47int
48XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks) 48XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks)
49{ 49{
50 XIEventMask *current; 50 XIEventMask *current;
51 xXISelectEventsReq *req; 51 xXISelectEventsReq *req;
52 xXIEventMask mask; 52 xXIEventMask mask;
53 int i; 53 int i;
54 int len = 0; 54 int len = 0;
55 int r = Success; 55 int r = Success;
 56 int max_mask_len = 0;
 57 char *buff;
56 58
57 XExtDisplayInfo *info = XInput_find_display(dpy); 59 XExtDisplayInfo *info = XInput_find_display(dpy);
58 LockDisplay(dpy); 60 LockDisplay(dpy);
59 if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1) { 61 if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1) {
60 r = NoSuchExtension; 62 r = NoSuchExtension;
61 goto out; 63 goto out;
62 } 64 }
 65
 66 for (i = 0; i < num_masks; i++) {
 67 current = &masks[i];
 68 if (current->mask_len > INT_MAX - 3 ||
 69 (current->mask_len + 3)/4 >= 0xffff) {
 70 r = -1;
 71 goto out;
 72 }
 73 if (current->mask_len > max_mask_len)
 74 max_mask_len = current->mask_len;
 75 }
 76
 77 /* max_mask_len is in bytes, but we need 4-byte units on the wire,
 78 * and they need to be padded with 0 */
 79 buff = calloc(4, ((max_mask_len + 3)/4));
 80 if (!buff) {
 81 r = -1;
 82 goto out;
 83 }
 84
63 GetReq(XISelectEvents, req); 85 GetReq(XISelectEvents, req);
64 86
65 req->reqType = info->codes->major_opcode; 87 req->reqType = info->codes->major_opcode;
66 req->ReqType = X_XISelectEvents; 88 req->ReqType = X_XISelectEvents;
67 req->win = win; 89 req->win = win;
68 req->num_masks = num_masks; 90 req->num_masks = num_masks;
69 91
70 /* get the right length */ 92 /* get the right length */
71 for (i = 0; i < num_masks; i++) 93 for (i = 0; i < num_masks; i++)
72 { 94 {
73 len++; 95 len++;
74 current = &masks[i]; 96 current = &masks[i];
75 len += (current->mask_len + 3)/4; 97 len += (current->mask_len + 3)/4;
76 } 98 }
77 99
78 SetReqLen(req, len, len); 100 SetReqLen(req, len, len);
79 101
80 for (i = 0; i < num_masks; i++) 102 for (i = 0; i < num_masks; i++)
81 { 103 {
82 char *buff; 
83 current = &masks[i]; 104 current = &masks[i];
84 mask.deviceid = current->deviceid; 105 mask.deviceid = current->deviceid;
85 mask.mask_len = (current->mask_len + 3)/4; 106 mask.mask_len = (current->mask_len + 3)/4;
86 /* masks.mask_len is in bytes, but we need 4-byte units on the wire, 107
87 * and they need to be padded with 0 */ 108 memset(buff, 0, max_mask_len);
88 buff = calloc(1, mask.mask_len * 4); 
89 memcpy(buff, current->mask, current->mask_len); 109 memcpy(buff, current->mask, current->mask_len);
90 Data(dpy, (char*)&mask, sizeof(xXIEventMask)); 110 Data(dpy, (char*)&mask, sizeof(xXIEventMask));
91 Data(dpy, buff, mask.mask_len * 4); 111 Data(dpy, buff, mask.mask_len * 4);
92 free(buff); 
93 } 112 }
94 113
 114 free(buff);
95out: 115out:
96 UnlockDisplay(dpy); 116 UnlockDisplay(dpy);
97 SyncHandle(); 117 SyncHandle();
98 return r; 118 return r;
99 119
100} 120}
101 121
102XIEventMask* 122XIEventMask*
103XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return) 123XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return)
104{ 124{
105 unsigned int i, len = 0; 125 unsigned int i, len = 0;
106 unsigned char *mask; 126 unsigned char *mask;
107 XIEventMask *mask_out = NULL; 127 XIEventMask *mask_out = NULL;
@@ -132,28 +152,34 @@ XIGetSelectedEvents(Display* dpy, Window @@ -132,28 +152,34 @@ XIGetSelectedEvents(Display* dpy, Window
132 } 152 }
133 153
134 if (reply.length < (INT_MAX >> 2)) { 154 if (reply.length < (INT_MAX >> 2)) {
135 rbytes = (unsigned long) reply.length << 2; 155 rbytes = (unsigned long) reply.length << 2;
136 mask_in = Xmalloc(rbytes); 156 mask_in = Xmalloc(rbytes);
137 } 157 }
138 if (!mask_in) { 158 if (!mask_in) {
139 _XEatDataWords(dpy, reply.length); 159 _XEatDataWords(dpy, reply.length);
140 goto out; 160 goto out;
141 } 161 }
142 162
143 _XRead(dpy, (char*)mask_in, rbytes); 163 _XRead(dpy, (char*)mask_in, rbytes);
144 164
145 /* Memory layout of the XIEventMask for a 3 mask reply: 165 /*
146 * [struct a][struct b][struct c][masks a][masks b][masks c] 166 * This function takes interleaved xXIEventMask structs & masks off
 167 * the wire, such as this 3 mask reply:
 168 * [struct a][masks a][struct b][masks b][struct c][masks c]
 169 * And generates a memory buffer to be returned to callers in which
 170 * they are not interleaved, so that callers can treat the returned
 171 * pointer as a simple array of XIEventMask structs, such as:
 172 * [struct a][struct b][struct c][masks a][masks b][masks c]
147 */ 173 */
148 len = reply.num_masks * sizeof(XIEventMask); 174 len = reply.num_masks * sizeof(XIEventMask);
149 175
150 for (i = 0, mi = mask_in; i < reply.num_masks; i++) 176 for (i = 0, mi = mask_in; i < reply.num_masks; i++)
151 { 177 {
152 unsigned int mask_bytes = mi->mask_len * 4; 178 unsigned int mask_bytes = mi->mask_len * 4;
153 len += mask_bytes; 179 len += mask_bytes;
154 if (len > INT_MAX) 180 if (len > INT_MAX)
155 goto out; 181 goto out;
156 if ((sizeof(xXIEventMask) + mask_bytes) > rbytes) 182 if ((sizeof(xXIEventMask) + mask_bytes) > rbytes)
157 goto out; 183 goto out;
158 rbytes -= (sizeof(xXIEventMask) + mask_bytes); 184 rbytes -= (sizeof(xXIEventMask) + mask_bytes);
159 mi = (xXIEventMask*)((char*)mi + mask_bytes); 185 mi = (xXIEventMask*)((char*)mi + mask_bytes);

cvs diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XListDev.c (expand / switch to unified diff)

--- xsrc/external/mit/libXi/dist/src/XListDev.c 2013/06/06 06:46:32 1.2
+++ xsrc/external/mit/libXi/dist/src/XListDev.c 2014/03/16 22:27:35 1.3
@@ -194,27 +194,27 @@ XListInputDevices( @@ -194,27 +194,27 @@ XListInputDevices(
194 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { 194 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
195 UnlockDisplay(dpy); 195 UnlockDisplay(dpy);
196 SyncHandle(); 196 SyncHandle();
197 return (XDeviceInfo *) NULL; 197 return (XDeviceInfo *) NULL;
198 } 198 }
199 199
200 if ((*ndevices = rep.ndevices)) { /* at least 1 input device */ 200 if ((*ndevices = rep.ndevices)) { /* at least 1 input device */
201 size = *ndevices * sizeof(XDeviceInfo); 201 size = *ndevices * sizeof(XDeviceInfo);
202 if (rep.length < (INT_MAX >> 2)) { 202 if (rep.length < (INT_MAX >> 2)) {
203 rlen = rep.length << 2; /* multiply length by 4 */ 203 rlen = rep.length << 2; /* multiply length by 4 */
204 slist = list = Xmalloc(rlen); 204 slist = list = Xmalloc(rlen);
205 } 205 }
206 if (!slist) { 206 if (!slist) {
207 _XEatData(dpy, (unsigned long)rlen); 207 _XEatDataWords(dpy, rep.length);
208 UnlockDisplay(dpy); 208 UnlockDisplay(dpy);
209 SyncHandle(); 209 SyncHandle();
210 return (XDeviceInfo *) NULL; 210 return (XDeviceInfo *) NULL;
211 } 211 }
212 _XRead(dpy, (char *)list, rlen); 212 _XRead(dpy, (char *)list, rlen);
213 213
214 any = (xAnyClassPtr) ((char *)list + (*ndevices * sizeof(xDeviceInfo))); 214 any = (xAnyClassPtr) ((char *)list + (*ndevices * sizeof(xDeviceInfo)));
215 sav_any = any; 215 sav_any = any;
216 for (i = 0; i < *ndevices; i++, list++) { 216 for (i = 0; i < *ndevices; i++, list++) {
217 size += SizeClassInfo(&any, (int)list->num_classes); 217 size += SizeClassInfo(&any, (int)list->num_classes);
218 } 218 }
219 219
220 Nptr = ((unsigned char *)list) + rlen + 1; 220 Nptr = ((unsigned char *)list) + rlen + 1;

cvs diff -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XQueryDv.c (expand / switch to unified diff)

--- xsrc/external/mit/libXi/dist/src/XQueryDv.c 2013/06/06 06:46:32 1.2
+++ xsrc/external/mit/libXi/dist/src/XQueryDv.c 2014/03/16 22:27:35 1.3
@@ -84,27 +84,27 @@ XQueryDeviceState( @@ -84,27 +84,27 @@ XQueryDeviceState(
84 req->reqType = info->codes->major_opcode; 84 req->reqType = info->codes->major_opcode;
85 req->ReqType = X_QueryDeviceState; 85 req->ReqType = X_QueryDeviceState;
86 req->deviceid = dev->device_id; 86 req->deviceid = dev->device_id;
87 87
88 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) 88 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
89 goto out; 89 goto out;
90 90
91 if (rep.length > 0) { 91 if (rep.length > 0) {
92 if (rep.length < (INT_MAX >> 2)) { 92 if (rep.length < (INT_MAX >> 2)) {
93 rlen = (unsigned long) rep.length << 2; 93 rlen = (unsigned long) rep.length << 2;
94 data = Xmalloc(rlen); 94 data = Xmalloc(rlen);
95 } 95 }
96 if (!data) { 96 if (!data) {
97 _XEatData(dpy, (unsigned long)rlen); 97 _XEatDataWords(dpy, rep.length);
98 goto out; 98 goto out;
99 } 99 }
100 _XRead(dpy, data, rlen); 100 _XRead(dpy, data, rlen);
101 101
102 for (i = 0, any = (XInputClass *) data; i < (int)rep.num_classes; i++) { 102 for (i = 0, any = (XInputClass *) data; i < (int)rep.num_classes; i++) {
103 if (any->length > rlen) 103 if (any->length > rlen)
104 goto out; 104 goto out;
105 rlen -= any->length; 105 rlen -= any->length;
106 106
107 switch (any->class) { 107 switch (any->class) {
108 case KeyClass: 108 case KeyClass:
109 size += sizeof(XKeyState); 109 size += sizeof(XKeyState);
110 break; 110 break;

cvs diff -r1.3 -r1.4 xsrc/external/mit/libXi/dist/src/XGetFCtl.c (expand / switch to unified diff)

--- xsrc/external/mit/libXi/dist/src/XGetFCtl.c 2013/06/27 21:57:21 1.3
+++ xsrc/external/mit/libXi/dist/src/XGetFCtl.c 2014/03/16 22:27:35 1.4
@@ -91,27 +91,27 @@ XGetFeedbackControl( @@ -91,27 +91,27 @@ XGetFeedbackControl(
91 91
92 if (rep.length > 0) { 92 if (rep.length > 0) {
93 unsigned long nbytes; 93 unsigned long nbytes;
94 size_t size = 0; 94 size_t size = 0;
95 int i; 95 int i;
96 96
97 *num_feedbacks = rep.num_feedbacks; 97 *num_feedbacks = rep.num_feedbacks;
98 98
99 if (rep.length < (INT_MAX >> 2)) { 99 if (rep.length < (INT_MAX >> 2)) {
100 nbytes = rep.length << 2; 100 nbytes = rep.length << 2;
101 f = Xmalloc(nbytes); 101 f = Xmalloc(nbytes);
102 } 102 }
103 if (!f) { 103 if (!f) {
104 _XEatData(dpy, (unsigned long)nbytes); 104 _XEatDataWords(dpy, rep.length);
105 goto out; 105 goto out;
106 } 106 }
107 sav = f; 107 sav = f;
108 _XRead(dpy, (char *)f, nbytes); 108 _XRead(dpy, (char *)f, nbytes);
109 109
110 for (i = 0; i < *num_feedbacks; i++) { 110 for (i = 0; i < *num_feedbacks; i++) {
111 if (f->length > nbytes) 111 if (f->length > nbytes)
112 goto out; 112 goto out;
113 nbytes -= f->length; 113 nbytes -= f->length;
114 114
115 switch (f->class) { 115 switch (f->class) {
116 case KbdFeedbackClass: 116 case KbdFeedbackClass:
117 size += sizeof(XKbdFeedbackState); 117 size += sizeof(XKbdFeedbackState);