# # Updated but not checked in: # (will commit) # # modified: Xi/chgfctl.c # modified: Xi/chgkmap.c # modified: Xi/chgprop.c # modified: Xi/grabdev.c # modified: Xi/grabdevb.c # modified: Xi/grabdevk.c # modified: Xi/selectev.c # modified: Xi/sendexev.c # diff --git a/Xi/chgfctl.c b/Xi/chgfctl.c index 46bb8e7..1a02eee 100644 --- a/Xi/chgfctl.c +++ b/Xi/chgfctl.c @@ -303,18 +303,13 @@ ChangeStringFeedback(ClientPtr client, D xStringFeedbackCtl * f) { char n; - long *p; int i, j; KeySym *syms, *sup_syms; syms = (KeySym *) (f + 1); if (client->swapped) { swaps(&f->length, n); /* swapped num_keysyms in calling proc */ - p = (long *)(syms); - for (i = 0; i < f->num_keysyms; i++) { - swapl(p, n); - p++; - } + SwapLongs((CARD32 *) syms, f->num_keysyms); } if (f->num_keysyms > s->ctrl.max_symbols) diff --git a/Xi/chgkmap.c b/Xi/chgkmap.c index bfdc1ce..d0b29b8 100644 --- a/Xi/chgkmap.c +++ b/Xi/chgkmap.c @@ -76,18 +76,14 @@ int SProcXChangeDeviceKeyMapping(ClientPtr client) { char n; - long *p; - int i, count; + unsigned int count; REQUEST(xChangeDeviceKeyMappingReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq); - p = (long *)&stuff[1]; count = stuff->keyCodes * stuff->keySymsPerKeyCode; - for (i = 0; i < count; i++) { - swapl(p, n); - p++; - } + REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32)); + SwapLongs((CARD32 *) (&stuff[1]), count); return (ProcXChangeDeviceKeyMapping(client)); } @@ -103,10 +99,14 @@ ProcXChangeDeviceKeyMapping(ClientPtr cl int ret; unsigned len; DeviceIntPtr dev; + unsigned int count; REQUEST(xChangeDeviceKeyMappingReq); REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq); + count = stuff->keyCodes * stuff->keySymsPerKeyCode; + REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32)); + dev = LookupDeviceIntRec(stuff->deviceid); if (dev == NULL) return BadDevice; diff --git a/Xi/chgprop.c b/Xi/chgprop.c index 13463dd..c6e6993 100644 --- a/Xi/chgprop.c +++ b/Xi/chgprop.c @@ -78,19 +78,15 @@ int SProcXChangeDeviceDontPropagateList(ClientPtr client) { char n; - long *p; - int i; REQUEST(xChangeDeviceDontPropagateListReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq); swapl(&stuff->window, n); swaps(&stuff->count, n); - p = (long *)&stuff[1]; - for (i = 0; i < stuff->count; i++) { - swapl(p, n); - p++; - } + REQUEST_FIXED_SIZE(xChangeDeviceDontPropagateListReq, + stuff->count * sizeof(CARD32)); + SwapLongs((CARD32 *) (&stuff[1]), stuff->count); return (ProcXChangeDeviceDontPropagateList(client)); } diff --git a/Xi/grabdev.c b/Xi/grabdev.c index b303695..8cca85f 100644 --- a/Xi/grabdev.c +++ b/Xi/grabdev.c @@ -79,8 +79,6 @@ int SProcXGrabDevice(ClientPtr client) { char n; - long *p; - int i; REQUEST(xGrabDeviceReq); swaps(&stuff->length, n); @@ -88,11 +86,11 @@ SProcXGrabDevice(ClientPtr client) swapl(&stuff->grabWindow, n); swapl(&stuff->time, n); swaps(&stuff->event_count, n); - p = (long *)&stuff[1]; - for (i = 0; i < stuff->event_count; i++) { - swapl(p, n); - p++; - } + + if (stuff->length != (sizeof(xGrabDeviceReq) >> 2) + stuff->event_count) + return BadLength; + + SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count); return (ProcXGrabDevice(client)); } diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c index 21e46fc..3674441 100644 --- a/Xi/grabdevb.c +++ b/Xi/grabdevb.c @@ -77,8 +77,6 @@ int SProcXGrabDeviceButton(ClientPtr client) { char n; - long *p; - int i; REQUEST(xGrabDeviceButtonReq); swaps(&stuff->length, n); @@ -86,11 +84,9 @@ SProcXGrabDeviceButton(ClientPtr client) swapl(&stuff->grabWindow, n); swaps(&stuff->modifiers, n); swaps(&stuff->event_count, n); - p = (long *)&stuff[1]; - for (i = 0; i < stuff->event_count; i++) { - swapl(p, n); - p++; - } + REQUEST_FIXED_SIZE(xGrabDeviceButtonReq, + stuff->event_count * sizeof(CARD32)); + SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count); return (ProcXGrabDeviceButton(client)); } diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c index 8da36ba..b6374c1 100644 --- a/Xi/grabdevk.c +++ b/Xi/grabdevk.c @@ -77,8 +77,6 @@ int SProcXGrabDeviceKey(ClientPtr client) { char n; - long *p; - int i; REQUEST(xGrabDeviceKeyReq); swaps(&stuff->length, n); @@ -86,11 +84,8 @@ SProcXGrabDeviceKey(ClientPtr client) swapl(&stuff->grabWindow, n); swaps(&stuff->modifiers, n); swaps(&stuff->event_count, n); - p = (long *)&stuff[1]; - for (i = 0; i < stuff->event_count; i++) { - swapl(p, n); - p++; - } + REQUEST_FIXED_SIZE(xGrabDeviceKeyReq, stuff->event_count * sizeof(CARD32)); + SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count); return (ProcXGrabDeviceKey(client)); } diff --git a/Xi/selectev.c b/Xi/selectev.c index a5cf567..2fb8aa7 100644 --- a/Xi/selectev.c +++ b/Xi/selectev.c @@ -128,19 +128,16 @@ int SProcXSelectExtensionEvent(ClientPtr client) { char n; - long *p; - int i; REQUEST(xSelectExtensionEventReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq); swapl(&stuff->window, n); swaps(&stuff->count, n); - p = (long *)&stuff[1]; - for (i = 0; i < stuff->count; i++) { - swapl(p, n); - p++; - } + REQUEST_FIXED_SIZE(xSelectExtensionEventReq, + stuff->count * sizeof(CARD32)); + SwapLongs((CARD32 *) (&stuff[1]), stuff->count); + return (ProcXSelectExtensionEvent(client)); } diff --git a/Xi/sendexev.c b/Xi/sendexev.c index 20b415a..5292ad2 100644 --- a/Xi/sendexev.c +++ b/Xi/sendexev.c @@ -80,7 +80,7 @@ int SProcXSendExtensionEvent(ClientPtr client) { char n; - long *p; + CARD32 *p; int i; xEvent eventT; xEvent *eventP; @@ -91,6 +91,11 @@ SProcXSendExtensionEvent(ClientPtr clien REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq); swapl(&stuff->destination, n); swaps(&stuff->count, n); + + if (stuff->length != (sizeof(xSendExtensionEventReq) >> 2) + stuff->count + + (stuff->num_events * (sizeof(xEvent) >> 2))) + return BadLength; + eventP = (xEvent *) & stuff[1]; for (i = 0; i < stuff->num_events; i++, eventP++) { proc = EventSwapVector[eventP->u.u.type & 0177]; @@ -100,11 +105,8 @@ SProcXSendExtensionEvent(ClientPtr clien *eventP = eventT; } - p = (long *)(((xEvent *) & stuff[1]) + stuff->num_events); - for (i = 0; i < stuff->count; i++) { - swapl(p, n); - p++; - } + p = (CARD32 *)(((xEvent *) & stuff[1]) + stuff->num_events); + SwapLongs(p, stuff->count); return (ProcXSendExtensionEvent(client)); }