Module Name:    xsrc
Committed By:   mrg
Date:           Sun Mar 16 22:27:36 UTC 2014

Modified Files:
        xsrc/external/mit/libXfont/dist/src/FreeType: ftfuncs.c
        xsrc/external/mit/libXi/dist/src: XGMotion.c XGetDCtl.c XGetDProp.c
            XGetFCtl.c XGetProp.c XIPassiveGrab.c XIProperties.c XISelEv.c
            XListDev.c XQueryDv.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
    xsrc/external/mit/libXfont/dist/src/FreeType/ftfuncs.c
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/libXi/dist/src/XGMotion.c \
    xsrc/external/mit/libXi/dist/src/XGetDCtl.c \
    xsrc/external/mit/libXi/dist/src/XGetDProp.c \
    xsrc/external/mit/libXi/dist/src/XGetProp.c \
    xsrc/external/mit/libXi/dist/src/XIPassiveGrab.c \
    xsrc/external/mit/libXi/dist/src/XIProperties.c \
    xsrc/external/mit/libXi/dist/src/XISelEv.c \
    xsrc/external/mit/libXi/dist/src/XListDev.c \
    xsrc/external/mit/libXi/dist/src/XQueryDv.c
cvs rdiff -u -r1.3 -r1.4 xsrc/external/mit/libXi/dist/src/XGetFCtl.c

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/libXfont/dist/src/FreeType/ftfuncs.c
diff -u xsrc/external/mit/libXfont/dist/src/FreeType/ftfuncs.c:1.3 xsrc/external/mit/libXfont/dist/src/FreeType/ftfuncs.c:1.4
--- xsrc/external/mit/libXfont/dist/src/FreeType/ftfuncs.c:1.3	Fri May 31 01:18:45 2013
+++ xsrc/external/mit/libXfont/dist/src/FreeType/ftfuncs.c	Sun Mar 16 22:27:35 2014
@@ -2050,7 +2050,7 @@ restrict_code_range_by_str(int count,uns
 {
     int nRanges = 0;
     int result = 0;
-    fsRange *ranges = NULL;
+    fsRange *ranges = NULL, *oldRanges;
     char const *p, *q;
 
     p = q = str;
@@ -2119,10 +2119,13 @@ restrict_code_range_by_str(int count,uns
         fflush(stderr);
 #endif
         nRanges++;
+        oldRanges = ranges;
         ranges = realloc(ranges, nRanges*sizeof(*ranges));
-        if (NULL == ranges)
+        if (NULL == ranges) {
+            free(oldRanges);
             break;
-        {
+        }
+        else {
             fsRange *r = ranges+nRanges-1;
 
             r->min_char_low = minpoint & 0xff;
@@ -2204,7 +2207,7 @@ FreeTypeSetUpTTCap( char *fileName, Font
 		strcpy(*dynStrRealFileName+dirLen, p2+1);
 		capHead = p1;
 	    } else {
-		*dynStrRealFileName = xstrdup(fileName);
+		*dynStrRealFileName = strdup(fileName);
 		if( *dynStrRealFileName == NULL ) {
 		    result = AllocError;
 		    goto quit;
@@ -2289,13 +2292,11 @@ FreeTypeSetUpTTCap( char *fileName, Font
 	    }
 	}
 	else{
-	    *dynStrFTFileName = malloc(strlen(*dynStrRealFileName)+1);
+	    *dynStrFTFileName = strdup(*dynStrRealFileName);
 	    if( *dynStrFTFileName == NULL ){
 		result = AllocError;
 		goto quit;
 	    }
-	    **dynStrFTFileName = '\0';
-	    strcat(*dynStrFTFileName,*dynStrRealFileName);
 	}
     }
     /*
@@ -2549,7 +2550,7 @@ FreeTypeSetUpTTCap( char *fileName, Font
     if (SPropRecValList_search_record(&listPropRecVal,
 				      &contRecValue,
 				      "CodeRange")) {
-	*dynStrTTCapCodeRange = xstrdup(SPropContainer_value_str(contRecValue));
+	*dynStrTTCapCodeRange = strdup(SPropContainer_value_str(contRecValue));
 	if( *dynStrTTCapCodeRange == NULL ) {
 	    result = AllocError;
 	    goto quit;

Index: xsrc/external/mit/libXi/dist/src/XGMotion.c
diff -u xsrc/external/mit/libXi/dist/src/XGMotion.c:1.2 xsrc/external/mit/libXi/dist/src/XGMotion.c:1.3
--- xsrc/external/mit/libXi/dist/src/XGMotion.c:1.2	Thu Jun  6 06:46:32 2013
+++ xsrc/external/mit/libXi/dist/src/XGMotion.c	Sun Mar 16 22:27:35 2014
@@ -124,7 +124,7 @@ XGetDeviceMotionEvents(
 	Xfree(bufp);
 	Xfree(savp);
 	*nEvents = 0;
-	_XEatData(dpy, (unsigned long)size);
+	_XEatDataWords(dpy, rep.length);
 	UnlockDisplay(dpy);
 	SyncHandle();
 	return (NULL);
Index: xsrc/external/mit/libXi/dist/src/XGetDCtl.c
diff -u xsrc/external/mit/libXi/dist/src/XGetDCtl.c:1.2 xsrc/external/mit/libXi/dist/src/XGetDCtl.c:1.3
--- xsrc/external/mit/libXi/dist/src/XGetDCtl.c:1.2	Thu Jun  6 06:46:32 2013
+++ xsrc/external/mit/libXi/dist/src/XGetDCtl.c	Sun Mar 16 22:27:35 2014
@@ -98,7 +98,7 @@ XGetDeviceControl(
 	    d = Xmalloc(nbytes);
 	}
 	if (!d) {
-	    _XEatData(dpy, (unsigned long)nbytes);
+	    _XEatDataWords(dpy, rep.length);
 	    goto out;
 	}
 	sav = d;
@@ -122,34 +122,34 @@ XGetDeviceControl(
 	    val_size = 3 * sizeof(int) * r->num_valuators;
 	    if ((sizeof(xDeviceResolutionState) + val_size) > nbytes)
 		goto out;
-	    size += sizeof(XDeviceResolutionState) + val_size;
+	    size = sizeof(XDeviceResolutionState) + val_size;
 	    break;
 	}
         case DEVICE_ABS_CALIB:
         {
             if (sizeof(xDeviceAbsCalibState) > nbytes)
                 goto out;
-            size += sizeof(XDeviceAbsCalibState);
+            size = sizeof(XDeviceAbsCalibState);
             break;
         }
         case DEVICE_ABS_AREA:
         {
             if (sizeof(xDeviceAbsAreaState) > nbytes)
                 goto out;
-            size += sizeof(XDeviceAbsAreaState);
+            size = sizeof(XDeviceAbsAreaState);
             break;
         }
         case DEVICE_CORE:
         {
             if (sizeof(xDeviceCoreState) > nbytes)
                 goto out;
-            size += sizeof(XDeviceCoreState);
+            size = sizeof(XDeviceCoreState);
             break;
         }
 	default:
 	    if (d->length > nbytes)
 		goto out;
-	    size += d->length;
+	    size = d->length;
 	    break;
 	}
 
Index: xsrc/external/mit/libXi/dist/src/XGetDProp.c
diff -u xsrc/external/mit/libXi/dist/src/XGetDProp.c:1.2 xsrc/external/mit/libXi/dist/src/XGetDProp.c:1.3
--- xsrc/external/mit/libXi/dist/src/XGetDProp.c:1.2	Thu Jun  6 06:46:32 2013
+++ xsrc/external/mit/libXi/dist/src/XGetDProp.c	Sun Mar 16 22:27:35 2014
@@ -130,7 +130,7 @@ XGetDeviceProperty(Display* dpy, XDevice
 	    ret = BadImplementation;
 	}
 	if (! *prop) {
-	    _XEatData(dpy, (unsigned long) nbytes);
+	    _XEatDataWords(dpy, rep.length);
 	    if (ret == Success)
 		ret = BadAlloc;
 	    goto out;
Index: xsrc/external/mit/libXi/dist/src/XGetProp.c
diff -u xsrc/external/mit/libXi/dist/src/XGetProp.c:1.2 xsrc/external/mit/libXi/dist/src/XGetProp.c:1.3
--- xsrc/external/mit/libXi/dist/src/XGetProp.c:1.2	Thu Jun  6 06:46:32 2013
+++ xsrc/external/mit/libXi/dist/src/XGetProp.c	Sun Mar 16 22:27:35 2014
@@ -69,7 +69,6 @@ XGetDeviceDontPropagateList(
     int			*count)
 {
     XEventClass *list = NULL;
-    int rlen;
     xGetDeviceDontPropagateListReq *req;
     xGetDeviceDontPropagateListReply rep;
     XExtDisplayInfo *info = XInput_find_display(dpy);
@@ -93,7 +92,6 @@ XGetDeviceDontPropagateList(
     if (rep.length != 0) {
 	if ((rep.count != 0) && (rep.length < (INT_MAX / sizeof(XEventClass))))
 	    list = Xmalloc(rep.length * sizeof(XEventClass));
-	rlen = rep.length << 2;
 	if (list) {
 	    unsigned int i;
 	    CARD32 ec;
@@ -106,8 +104,10 @@ XGetDeviceDontPropagateList(
 		_XRead(dpy, (char *)(&ec), sizeof(CARD32));
 		list[i] = (XEventClass) ec;
 	    }
-	} else
-	    _XEatData(dpy, (unsigned long)rlen);
+	} else {
+            *count = 0;
+	    _XEatDataWords(dpy, rep.length);
+        }
     }
 
     UnlockDisplay(dpy);
Index: xsrc/external/mit/libXi/dist/src/XIPassiveGrab.c
diff -u xsrc/external/mit/libXi/dist/src/XIPassiveGrab.c:1.2 xsrc/external/mit/libXi/dist/src/XIPassiveGrab.c:1.3
--- xsrc/external/mit/libXi/dist/src/XIPassiveGrab.c:1.2	Thu Jun  6 06:46:32 2013
+++ xsrc/external/mit/libXi/dist/src/XIPassiveGrab.c	Sun Mar 16 22:27:35 2014
@@ -30,6 +30,7 @@
 #include <X11/extensions/XI2proto.h>
 #include <X11/extensions/XInput2.h>
 #include <X11/extensions/extutil.h>
+#include <limits.h>
 #include "XIint.h"
 
 static int
@@ -51,6 +52,14 @@ _XIPassiveGrabDevice(Display* dpy, int d
     if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1)
 	return -1;
 
+    if (mask->mask_len > INT_MAX - 3 ||
+        (mask->mask_len + 3)/4 >= 0xffff)
+        return -1;
+
+    buff = calloc(4, (mask->mask_len + 3)/4);
+    if (!buff)
+        return -1;
+
     GetReq(XIPassiveGrabDevice, req);
     req->reqType = extinfo->codes->major_opcode;
     req->ReqType = X_XIPassiveGrabDevice;
@@ -68,7 +77,6 @@ _XIPassiveGrabDevice(Display* dpy, int d
     len = req->mask_len + num_modifiers;
     SetReqLen(req, len, len);
 
-    buff = calloc(4, req->mask_len);
     memcpy(buff, mask->mask, mask->mask_len);
     Data(dpy, buff, req->mask_len * 4);
     for (i = 0; i < num_modifiers; i++)
Index: xsrc/external/mit/libXi/dist/src/XIProperties.c
diff -u xsrc/external/mit/libXi/dist/src/XIProperties.c:1.2 xsrc/external/mit/libXi/dist/src/XIProperties.c:1.3
--- xsrc/external/mit/libXi/dist/src/XIProperties.c:1.2	Thu Jun  6 06:46:32 2013
+++ xsrc/external/mit/libXi/dist/src/XIProperties.c	Sun Mar 16 22:27:35 2014
@@ -65,7 +65,7 @@ XIListProperties(Display* dpy, int devic
         props = (Atom*)Xmalloc(rep.num_properties * sizeof(Atom));
         if (!props)
         {
-            _XEatData(dpy, rep.num_properties << 2);
+            _XEatDataWords(dpy, rep.length);
             goto cleanup;
         }
 
@@ -204,8 +204,7 @@ XIGetProperty(Display* dpy, int deviceid
 	     * This part of the code should never be reached.  If it is,
 	     * the server sent back a property with an invalid format.
 	     */
-	    nbytes = rep.length << 2;
-	    _XEatData(dpy, nbytes);
+	    _XEatDataWords(dpy, rep.length);
 	    UnlockDisplay(dpy);
 	    SyncHandle();
 	    return(BadImplementation);
@@ -225,7 +224,7 @@ XIGetProperty(Display* dpy, int deviceid
 	}
 
 	if (!(*data)) {
-	    _XEatData(dpy, nbytes);
+	    _XEatDataWords(dpy, rep.length);
 	    UnlockDisplay(dpy);
 	    SyncHandle();
 	    return(BadAlloc);
Index: xsrc/external/mit/libXi/dist/src/XISelEv.c
diff -u xsrc/external/mit/libXi/dist/src/XISelEv.c:1.2 xsrc/external/mit/libXi/dist/src/XISelEv.c:1.3
--- xsrc/external/mit/libXi/dist/src/XISelEv.c:1.2	Thu Jun  6 06:46:32 2013
+++ xsrc/external/mit/libXi/dist/src/XISelEv.c	Sun Mar 16 22:27:35 2014
@@ -53,6 +53,8 @@ XISelectEvents(Display* dpy, Window win,
     int i;
     int len = 0;
     int r = Success;
+    int max_mask_len = 0;
+    char *buff;
 
     XExtDisplayInfo *info = XInput_find_display(dpy);
     LockDisplay(dpy);
@@ -60,6 +62,26 @@ XISelectEvents(Display* dpy, Window win,
         r = NoSuchExtension;
         goto out;
     }
+
+    for (i = 0; i < num_masks; i++) {
+        current = &masks[i];
+        if (current->mask_len > INT_MAX - 3 ||
+            (current->mask_len + 3)/4 >= 0xffff) {
+            r = -1;
+            goto out;
+        }
+        if (current->mask_len > max_mask_len)
+            max_mask_len = current->mask_len;
+    }
+
+    /* max_mask_len is in bytes, but we need 4-byte units on the wire,
+     * and they need to be padded with 0 */
+    buff = calloc(4, ((max_mask_len + 3)/4));
+    if (!buff) {
+        r = -1;
+        goto out;
+    }
+
     GetReq(XISelectEvents, req);
 
     req->reqType = info->codes->major_opcode;
@@ -79,19 +101,17 @@ XISelectEvents(Display* dpy, Window win,
 
     for (i = 0; i < num_masks; i++)
     {
-        char *buff;
         current = &masks[i];
         mask.deviceid = current->deviceid;
         mask.mask_len = (current->mask_len + 3)/4;
-        /* masks.mask_len is in bytes, but we need 4-byte units on the wire,
-         * and they need to be padded with 0 */
-        buff = calloc(1, mask.mask_len * 4);
+
+        memset(buff, 0, max_mask_len);
         memcpy(buff, current->mask, current->mask_len);
         Data(dpy, (char*)&mask, sizeof(xXIEventMask));
         Data(dpy, buff, mask.mask_len * 4);
-        free(buff);
     }
 
+    free(buff);
 out:
     UnlockDisplay(dpy);
     SyncHandle();
@@ -142,8 +162,14 @@ XIGetSelectedEvents(Display* dpy, Window
 
     _XRead(dpy, (char*)mask_in, rbytes);
 
-    /* Memory layout of the XIEventMask for a 3 mask reply:
-     * [struct a][struct b][struct c][masks a][masks b][masks c]
+    /*
+     * This function takes interleaved xXIEventMask structs & masks off
+     * the wire, such as this 3 mask reply:
+     *   [struct a][masks a][struct b][masks b][struct c][masks c]
+     * And generates a memory buffer to be returned to callers in which
+     * they are not interleaved, so that callers can treat the returned
+     * pointer as a simple array of XIEventMask structs, such as:
+     *   [struct a][struct b][struct c][masks a][masks b][masks c]
      */
     len = reply.num_masks * sizeof(XIEventMask);
 
Index: xsrc/external/mit/libXi/dist/src/XListDev.c
diff -u xsrc/external/mit/libXi/dist/src/XListDev.c:1.2 xsrc/external/mit/libXi/dist/src/XListDev.c:1.3
--- xsrc/external/mit/libXi/dist/src/XListDev.c:1.2	Thu Jun  6 06:46:32 2013
+++ xsrc/external/mit/libXi/dist/src/XListDev.c	Sun Mar 16 22:27:35 2014
@@ -204,7 +204,7 @@ XListInputDevices(
 	    slist = list = Xmalloc(rlen);
 	}
 	if (!slist) {
-	    _XEatData(dpy, (unsigned long)rlen);
+	    _XEatDataWords(dpy, rep.length);
 	    UnlockDisplay(dpy);
 	    SyncHandle();
 	    return (XDeviceInfo *) NULL;
Index: xsrc/external/mit/libXi/dist/src/XQueryDv.c
diff -u xsrc/external/mit/libXi/dist/src/XQueryDv.c:1.2 xsrc/external/mit/libXi/dist/src/XQueryDv.c:1.3
--- xsrc/external/mit/libXi/dist/src/XQueryDv.c:1.2	Thu Jun  6 06:46:32 2013
+++ xsrc/external/mit/libXi/dist/src/XQueryDv.c	Sun Mar 16 22:27:35 2014
@@ -94,7 +94,7 @@ XQueryDeviceState(
 	    data = Xmalloc(rlen);
 	}
 	if (!data) {
-	    _XEatData(dpy, (unsigned long)rlen);
+	    _XEatDataWords(dpy, rep.length);
 	    goto out;
 	}
 	_XRead(dpy, data, rlen);

Index: xsrc/external/mit/libXi/dist/src/XGetFCtl.c
diff -u xsrc/external/mit/libXi/dist/src/XGetFCtl.c:1.3 xsrc/external/mit/libXi/dist/src/XGetFCtl.c:1.4
--- xsrc/external/mit/libXi/dist/src/XGetFCtl.c:1.3	Thu Jun 27 21:57:21 2013
+++ xsrc/external/mit/libXi/dist/src/XGetFCtl.c	Sun Mar 16 22:27:35 2014
@@ -101,7 +101,7 @@ XGetFeedbackControl(
 	    f = Xmalloc(nbytes);
 	}
 	if (!f) {
-	    _XEatData(dpy, (unsigned long)nbytes);
+	    _XEatDataWords(dpy, rep.length);
 	    goto out;
 	}
 	sav = f;

Reply via email to