dix: switch to byte-counting functions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2009-07-03 16:50:03 +10:00
parent 7dd415aa6a
commit 2d35ea8d95
9 changed files with 54 additions and 53 deletions

View File

@ -1532,7 +1532,7 @@ ProcSetModifierMapping(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq); REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
if (client->req_len != ((stuff->numKeyPerModifier << 1) + if (client->req_len != ((stuff->numKeyPerModifier << 1) +
(sizeof (xSetModifierMappingReq) >> 2))) bytes_to_int32(sizeof(xSetModifierMappingReq))))
return BadLength; return BadLength;
rep.type = X_Reply; rep.type = X_Reply;
@ -1591,7 +1591,7 @@ ProcChangeKeyboardMapping(ClientPtr client)
int rc; int rc;
REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2); len = client->req_len - bytes_to_int32(sizeof(xChangeKeyboardMappingReq));
if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode)) if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode))
return BadLength; return BadLength;
@ -1650,7 +1650,8 @@ ProcSetPointerMapping(ClientPtr client)
REQUEST(xSetPointerMappingReq); REQUEST(xSetPointerMappingReq);
REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq); REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2) if (client->req_len !=
bytes_to_int32(sizeof(xSetPointerMappingReq) + stuff->nElts))
return BadLength; return BadLength;
rep.type = X_Reply; rep.type = X_Reply;
rep.length = 0; rep.length = 0;
@ -2229,7 +2230,7 @@ ProcGetMotionEvents(ClientPtr client)
nEvents++; nEvents++;
} }
} }
rep.length = nEvents * (sizeof(xTimecoord) >> 2); rep.length = nEvents * bytes_to_int32(sizeof(xTimecoord));
rep.nEvents = nEvents; rep.nEvents = nEvents;
WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep); WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep);
if (nEvents) if (nEvents)

View File

@ -513,7 +513,7 @@ CreateConnectionBlock(void)
QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode); QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode);
lenofblock = sizeof(xConnSetup) + lenofblock = sizeof(xConnSetup) +
((setup.nbytesVendor + 3) & ~3) + pad_to_int32(setup.nbytesVendor) +
(setup.numFormats * sizeof(xPixmapFormat)) + (setup.numFormats * sizeof(xPixmapFormat)) +
(setup.numRoots * sizeof(xWindowRoot)); (setup.numRoots * sizeof(xWindowRoot));
ConnectionInfo = xalloc(lenofblock); ConnectionInfo = xalloc(lenofblock);
@ -638,7 +638,7 @@ ProcCreateWindow(ClientPtr client)
rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess); rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
len = client->req_len - (sizeof(xCreateWindowReq) >> 2); len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq));
if (Ones(stuff->mask) != len) if (Ones(stuff->mask) != len)
return BadLength; return BadLength;
if (!stuff->width || !stuff->height) if (!stuff->width || !stuff->height)
@ -681,7 +681,7 @@ ProcChangeWindowAttributes(ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->window, client, access_mode); rc = dixLookupWindow(&pWin, stuff->window, client, access_mode);
if (rc != Success) if (rc != Success)
return rc; return rc;
len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2); len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq));
if (len != Ones(stuff->valueMask)) if (len != Ones(stuff->valueMask))
return BadLength; return BadLength;
result = ChangeWindowAttributes(pWin, result = ChangeWindowAttributes(pWin,
@ -885,7 +885,7 @@ ProcConfigureWindow(ClientPtr client)
DixManageAccess|DixSetAttrAccess); DixManageAccess|DixSetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
len = client->req_len - (sizeof(xConfigureWindowReq) >> 2); len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq));
if (Ones((Mask)stuff->mask) != len) if (Ones((Mask)stuff->mask) != len)
return BadLength; return BadLength;
result = ConfigureWindow(pWin, (Mask)stuff->mask, (XID *) &stuff[1], result = ConfigureWindow(pWin, (Mask)stuff->mask, (XID *) &stuff[1],
@ -1013,7 +1013,7 @@ ProcQueryTree(ClientPtr client)
} }
reply.nChildren = numChildren; reply.nChildren = numChildren;
reply.length = (numChildren * sizeof(Window)) >> 2; reply.length = bytes_to_int32(numChildren * sizeof(Window));
WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply); WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply);
if (numChildren) if (numChildren)
@ -1070,7 +1070,7 @@ ProcGetAtomName(ClientPtr client)
len = strlen(str); len = strlen(str);
memset(&reply, 0, sizeof(xGetAtomNameReply)); memset(&reply, 0, sizeof(xGetAtomNameReply));
reply.type = X_Reply; reply.type = X_Reply;
reply.length = (len + 3) >> 2; reply.length = bytes_to_int32(len);
reply.sequenceNumber = client->sequence; reply.sequenceNumber = client->sequence;
reply.nameLength = len; reply.nameLength = len;
WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply); WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply);
@ -1310,7 +1310,7 @@ ProcQueryFont(ClientPtr client)
} }
reply->type = X_Reply; reply->type = X_Reply;
reply->length = (rlength - sizeof(xGenericReply)) >> 2; reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
reply->sequenceNumber = client->sequence; reply->sequenceNumber = client->sequence;
QueryFont( pFont, reply, nprotoxcistructs); QueryFont( pFont, reply, nprotoxcistructs);
@ -1344,7 +1344,7 @@ ProcQueryTextExtents(ClientPtr client)
if (rc != Success) if (rc != Success)
return (rc == BadValue) ? BadFont: rc; return (rc == BadValue) ? BadFont: rc;
length = client->req_len - (sizeof(xQueryTextExtentsReq) >> 2); length = client->req_len - bytes_to_int32(sizeof(xQueryTextExtentsReq));
length = length << 1; length = length << 1;
if (stuff->oddLength) if (stuff->oddLength)
{ {
@ -1512,7 +1512,7 @@ ProcCreateGC(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
len = client->req_len - (sizeof(xCreateGCReq) >> 2); len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq));
if (len != Ones(stuff->mask)) if (len != Ones(stuff->mask))
return BadLength; return BadLength;
pGC = (GC *)CreateGC(pDraw, stuff->mask, (XID *) &stuff[1], &error, pGC = (GC *)CreateGC(pDraw, stuff->mask, (XID *) &stuff[1], &error,
@ -1537,7 +1537,7 @@ ProcChangeGC(ClientPtr client)
if (result != Success) if (result != Success)
return result; return result;
len = client->req_len - (sizeof(xChangeGCReq) >> 2); len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq));
if (len != Ones(stuff->mask)) if (len != Ones(stuff->mask))
return BadLength; return BadLength;
@ -1787,7 +1787,7 @@ ProcPolyPoint(ClientPtr client)
return BadValue; return BadValue;
} }
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2; npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
if (npoint) if (npoint)
(*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint, (*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint,
(xPoint *) &stuff[1]); (xPoint *) &stuff[1]);
@ -1810,7 +1810,7 @@ ProcPolyLine(ClientPtr client)
return BadValue; return BadValue;
} }
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2; npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
if (npoint > 1) if (npoint > 1)
(*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint, (*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint,
(DDXPointPtr) &stuff[1]); (DDXPointPtr) &stuff[1]);
@ -1898,7 +1898,7 @@ ProcFillPoly(ClientPtr client)
} }
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
things = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2; things = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
if (things) if (things)
(*pGC->ops->FillPolygon) (pDraw, pGC, stuff->shape, (*pGC->ops->FillPolygon) (pDraw, pGC, stuff->shape,
stuff->coordMode, things, stuff->coordMode, things,
@ -2042,8 +2042,8 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *)&stuff[1]; tmpImage = (char *)&stuff[1];
lengthProto = length; lengthProto = length;
if (((((lengthProto * stuff->height) + (unsigned)3) >> 2) + if ((bytes_to_int32(lengthProto * stuff->height) +
(sizeof(xPutImageReq) >> 2)) != client->req_len) bytes_to_int32(sizeof(xPutImageReq))) != client->req_len)
return BadLength; return BadLength;
ReformatImage (tmpImage, lengthProto * stuff->height, ReformatImage (tmpImage, lengthProto * stuff->height,
@ -2143,7 +2143,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
*(xGetImageReply *)pBuf = xgi; *(xGetImageReply *)pBuf = xgi;
pBuf += sz_xGetImageReply; pBuf += sz_xGetImageReply;
} else { } else {
xgi.length = (xgi.length + 3) >> 2; xgi.length = bytes_to_int32(xgi.length);
if (widthBytesLine == 0 || height == 0) if (widthBytesLine == 0 || height == 0)
linesPerBuf = 0; linesPerBuf = 0;
else if (widthBytesLine >= IMAGE_BUFSIZE) else if (widthBytesLine >= IMAGE_BUFSIZE)
@ -2705,7 +2705,7 @@ ProcAllocColorCells (ClientPtr client)
#endif #endif
{ {
accr.type = X_Reply; accr.type = X_Reply;
accr.length = length >> 2; accr.length = bytes_to_int32(length);
accr.sequenceNumber = client->sequence; accr.sequenceNumber = client->sequence;
accr.nPixels = npixels; accr.nPixels = npixels;
accr.nMasks = nmasks; accr.nMasks = nmasks;
@ -2769,7 +2769,7 @@ ProcAllocColorPlanes(ClientPtr client)
else else
return rc; return rc;
} }
acpr.length = length >> 2; acpr.length = bytes_to_int32(length);
#ifdef PANORAMIX #ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum) if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif #endif
@ -2804,7 +2804,7 @@ ProcFreeColors(ClientPtr client)
if(pcmp->flags & AllAllocated) if(pcmp->flags & AllAllocated)
return(BadAccess); return(BadAccess);
count = ((client->req_len << 2)- sizeof(xFreeColorsReq)) >> 2; count = bytes_to_int32((client->req_len << 2) - sizeof(xFreeColorsReq));
rc = FreeColors(pcmp, client->index, count, rc = FreeColors(pcmp, client->index, count,
(Pixel *)&stuff[1], (Pixel)stuff->planeMask); (Pixel *)&stuff[1], (Pixel)stuff->planeMask);
if (client->noClientException != Success) if (client->noClientException != Success)
@ -2907,7 +2907,7 @@ ProcQueryColors(ClientPtr client)
xrgb *prgbs; xrgb *prgbs;
xQueryColorsReply qcr; xQueryColorsReply qcr;
count = ((client->req_len << 2) - sizeof(xQueryColorsReq)) >> 2; count = bytes_to_int32((client->req_len << 2) - sizeof(xQueryColorsReq));
prgbs = xcalloc(1, count * sizeof(xrgb)); prgbs = xcalloc(1, count * sizeof(xrgb));
if(!prgbs && count) if(!prgbs && count)
return(BadAlloc); return(BadAlloc);
@ -2924,7 +2924,7 @@ ProcQueryColors(ClientPtr client)
} }
memset(&qcr, 0, sizeof(xQueryColorsReply)); memset(&qcr, 0, sizeof(xQueryColorsReply));
qcr.type = X_Reply; qcr.type = X_Reply;
qcr.length = (count * sizeof(xrgb)) >> 2; qcr.length = bytes_to_int32(count * sizeof(xrgb));
qcr.sequenceNumber = client->sequence; qcr.sequenceNumber = client->sequence;
qcr.nColors = count; qcr.nColors = count;
WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr); WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
@ -3294,7 +3294,7 @@ ProcListHosts(ClientPtr client)
reply.type = X_Reply; reply.type = X_Reply;
reply.sequenceNumber = client->sequence; reply.sequenceNumber = client->sequence;
reply.nHosts = nHosts; reply.nHosts = nHosts;
reply.length = len >> 2; reply.length = bytes_to_int32(len);
WriteReplyToClient(client, sizeof(xListHostsReply), &reply); WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
if (nHosts) if (nHosts)
{ {
@ -3427,7 +3427,7 @@ ProcGetFontPath(ClientPtr client)
reply.type = X_Reply; reply.type = X_Reply;
reply.sequenceNumber = client->sequence; reply.sequenceNumber = client->sequence;
reply.length = (stringLens + numpaths + 3) >> 2; reply.length = bytes_to_int32(stringLens + numpaths);
reply.nPaths = numpaths; reply.nPaths = numpaths;
WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply); WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
@ -3656,7 +3656,7 @@ ClientPtr NextAvailableClient(pointer ospriv)
return (ClientPtr)NULL; return (ClientPtr)NULL;
} }
data.reqType = 1; data.reqType = 1;
data.length = (sz_xReq + sz_xConnClientPrefix) >> 2; data.length = bytes_to_int32(sz_xReq + sz_xConnClientPrefix);
if (!InsertFakeRequest(client, (char *)&data, sz_xReq)) if (!InsertFakeRequest(client, (char *)&data, sz_xReq))
{ {
FreeClientResources(client); FreeClientResources(client);
@ -3696,8 +3696,8 @@ ProcInitialConnection(ClientPtr client)
SwapConnClientPrefix(prefix); SwapConnClientPrefix(prefix);
} }
stuff->reqType = 2; stuff->reqType = 2;
stuff->length += ((prefix->nbytesAuthProto + (unsigned)3) >> 2) + stuff->length += bytes_to_int32(prefix->nbytesAuthProto) +
((prefix->nbytesAuthString + (unsigned)3) >> 2); bytes_to_int32(prefix->nbytesAuthString);
if (client->swapped) if (client->swapped)
{ {
swaps(&stuff->length, whichbyte); swaps(&stuff->length, whichbyte);
@ -3721,7 +3721,7 @@ SendConnSetup(ClientPtr client, char *reason)
csp.success = xFalse; csp.success = xFalse;
csp.lengthReason = strlen(reason); csp.lengthReason = strlen(reason);
csp.length = (csp.lengthReason + (unsigned)3) >> 2; csp.length = bytes_to_int32(csp.lengthReason);
csp.majorVersion = X_PROTOCOL; csp.majorVersion = X_PROTOCOL;
csp.minorVersion = X_PROTOCOL_REVISION; csp.minorVersion = X_PROTOCOL_REVISION;
if (client->swapped) if (client->swapped)
@ -3812,7 +3812,7 @@ ProcEstablishConnection(ClientPtr client)
prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq); prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
auth_proto = (char *)prefix + sz_xConnClientPrefix; auth_proto = (char *)prefix + sz_xConnClientPrefix;
auth_string = auth_proto + ((prefix->nbytesAuthProto + 3) & ~3); auth_string = auth_proto + pad_to_int32(prefix->nbytesAuthProto);
if ((prefix->majorVersion != X_PROTOCOL) || if ((prefix->majorVersion != X_PROTOCOL) ||
(prefix->minorVersion != X_PROTOCOL_REVISION)) (prefix->minorVersion != X_PROTOCOL_REVISION))
reason = "Protocol version mismatch"; reason = "Protocol version mismatch";

View File

@ -792,7 +792,7 @@ finish:
memset(&reply, 0, sizeof(xListFontsReply)); memset(&reply, 0, sizeof(xListFontsReply));
reply.type = X_Reply; reply.type = X_Reply;
reply.length = (stringLens + nnames + 3) >> 2; reply.length = bytes_to_int32(stringLens + nnames);
reply.nFonts = nnames; reply.nFonts = nnames;
reply.sequenceNumber = client->sequence; reply.sequenceNumber = client->sequence;
@ -817,7 +817,7 @@ finish:
} }
} }
nnames = reply.nFonts; nnames = reply.nFonts;
reply.length = (stringLens + nnames + 3) >> 2; reply.length = bytes_to_int32(stringLens + nnames);
client->pSwapReplyFunc = ReplySwapVector[X_ListFonts]; client->pSwapReplyFunc = ReplySwapVector[X_ListFonts];
WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply); WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply);
(void) WriteToClient(client, stringLens + nnames, bufferStart); (void) WriteToClient(client, stringLens + nnames, bufferStart);
@ -1057,9 +1057,9 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
namelen = strlen(name); namelen = strlen(name);
} }
reply->type = X_Reply; reply->type = X_Reply;
reply->length = (sizeof *reply - sizeof(xGenericReply) + reply->length = bytes_to_int32(sizeof *reply - sizeof(xGenericReply) +
pFontInfo->nprops * sizeof(xFontProp) + pFontInfo->nprops * sizeof(xFontProp) +
namelen + 3) >> 2; namelen);
reply->sequenceNumber = client->sequence; reply->sequenceNumber = client->sequence;
reply->nameLength = namelen; reply->nameLength = namelen;
reply->minBounds = pFontInfo->ink_minbounds; reply->minBounds = pFontInfo->ink_minbounds;
@ -1097,8 +1097,8 @@ finish:
bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply)); bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply));
finalReply.type = X_Reply; finalReply.type = X_Reply;
finalReply.sequenceNumber = client->sequence; finalReply.sequenceNumber = client->sequence;
finalReply.length = (sizeof(xListFontsWithInfoReply) finalReply.length = bytes_to_int32(sizeof(xListFontsWithInfoReply)
- sizeof(xGenericReply)) >> 2; - sizeof(xGenericReply));
WriteSwappedDataToClient(client, length, &finalReply); WriteSwappedDataToClient(client, length, &finalReply);
bail: bail:
if (c->slept) if (c->slept)

View File

@ -389,13 +389,13 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
/* FIXME: this should just send the buttons we have, not MAX_BUTTONs. Same /* FIXME: this should just send the buttons we have, not MAX_BUTTONs. Same
* with MAX_VALUATORS below */ * with MAX_VALUATORS below */
/* btlen is in 4 byte units */ /* btlen is in 4 byte units */
btlen = (((MAX_BUTTONS + 7)/8) + 3)/4; btlen = bytes_to_int32(bits_to_bytes(MAX_BUTTONS));
len += btlen * 4; /* buttonmask len */ len += btlen * 4; /* buttonmask len */
vallen = count_bits(ev->valuators.mask, sizeof(ev->valuators.mask)/sizeof(ev->valuators.mask[0])); vallen = count_bits(ev->valuators.mask, sizeof(ev->valuators.mask)/sizeof(ev->valuators.mask[0]));
len += vallen * 2 * sizeof(uint32_t); /* axisvalues */ len += vallen * 2 * sizeof(uint32_t); /* axisvalues */
vallen = (((MAX_VALUATORS + 7)/8) + 3)/4; vallen = bytes_to_int32(bits_to_bytes(MAX_VALUATORS));
len += vallen * 4; /* valuators mask */ len += vallen * 4; /* valuators mask */
*xi = xcalloc(1, len); *xi = xcalloc(1, len);
@ -404,7 +404,7 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
xde->extension = IReqCode; xde->extension = IReqCode;
xde->evtype = GetXI2Type((InternalEvent*)ev); xde->evtype = GetXI2Type((InternalEvent*)ev);
xde->time = ev->time; xde->time = ev->time;
xde->length = (len - sizeof(xEvent) + 3)/4; xde->length = bytes_to_int32(len - sizeof(xEvent));
xde->detail = ev->detail.button; xde->detail = ev->detail.button;
xde->root = ev->root; xde->root = ev->root;
xde->buttons_len = btlen; xde->buttons_len = btlen;
@ -459,7 +459,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi)
nvals = count_bits(ev->valuators.mask, sizeof(ev->valuators.mask)/sizeof(ev->valuators.mask[0])); nvals = count_bits(ev->valuators.mask, sizeof(ev->valuators.mask)/sizeof(ev->valuators.mask[0]));
len += nvals * (2 * sizeof(uint32_t)) * 2; /* 8 byte per valuator, once len += nvals * (2 * sizeof(uint32_t)) * 2; /* 8 byte per valuator, once
raw, once processed */ raw, once processed */
vallen = (((MAX_VALUATORS + 7)/8) + 3)/4; vallen = bytes_to_int32(bits_to_bytes(MAX_VALUATORS));
len += vallen * 4; /* valuators mask */ len += vallen * 4; /* valuators mask */
*xi = xcalloc(1, len); *xi = xcalloc(1, len);
@ -468,7 +468,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi)
raw->extension = IReqCode; raw->extension = IReqCode;
raw->evtype = GetXI2Type((InternalEvent*)ev); raw->evtype = GetXI2Type((InternalEvent*)ev);
raw->time = ev->time; raw->time = ev->time;
raw->length = (len - sizeof(xEvent) + 3)/4; raw->length = bytes_to_int32(len - sizeof(xEvent));
raw->eventtype = ev->subtype; raw->eventtype = ev->subtype;
raw->detail = ev->detail.button; raw->detail = ev->detail.button;
raw->deviceid = ev->deviceid; raw->deviceid = ev->deviceid;

View File

@ -4221,8 +4221,8 @@ DeviceEnterLeaveEvent(
(mode == XINotifyPassiveUngrab && type == XI_Enter)) (mode == XINotifyPassiveUngrab && type == XI_Enter))
return; return;
btlen = (mouse->button) ? (mouse->button->numButtons + 7)/8 : 0; btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0;
btlen = (btlen + 3)/4; btlen = bytes_to_int32(btlen);
len = sizeof(xXIEnterEvent) + btlen * 4; len = sizeof(xXIEnterEvent) + btlen * 4;
event = xcalloc(1, len); event = xcalloc(1, len);

View File

@ -324,7 +324,7 @@ ProcListExtensions(ClientPtr client)
for (j = extensions[i]->num_aliases; --j >= 0;) for (j = extensions[i]->num_aliases; --j >= 0;)
total_length += strlen(extensions[i]->aliases[j]) + 1; total_length += strlen(extensions[i]->aliases[j]) + 1;
} }
reply.length = (total_length + 3) >> 2; reply.length = bytes_to_int32(total_length);
buffer = bufptr = xalloc(total_length); buffer = bufptr = xalloc(total_length);
if (!buffer) if (!buffer)
return(BadAlloc); return(BadAlloc);

View File

@ -218,7 +218,7 @@ ProcChangeProperty(ClientPtr client)
return BadValue; return BadValue;
} }
len = stuff->nUnits; len = stuff->nUnits;
if (len > ((0xffffffff - sizeof(xChangePropertyReq)) >> 2)) if (len > bytes_to_int32(0xffffffff - sizeof(xChangePropertyReq)))
return BadLength; return BadLength;
sizeInBytes = format>>3; sizeInBytes = format>>3;
totalSize = len * sizeInBytes; totalSize = len * sizeInBytes;
@ -532,7 +532,7 @@ ProcGetProperty(ClientPtr client)
reply.bytesAfter = n - (ind + len); reply.bytesAfter = n - (ind + len);
reply.format = pProp->format; reply.format = pProp->format;
reply.length = (len + 3) >> 2; reply.length = bytes_to_int32(len);
reply.nItems = len / (pProp->format / 8 ); reply.nItems = len / (pProp->format / 8 );
reply.propertyType = pProp->type; reply.propertyType = pProp->type;
@ -606,7 +606,7 @@ ProcListProperties(ClientPtr client)
xlpr.type = X_Reply; xlpr.type = X_Reply;
xlpr.nProperties = numProps; xlpr.nProperties = numProps;
xlpr.length = (numProps * sizeof(Atom)) >> 2; xlpr.length = bytes_to_int32(numProps * sizeof(Atom));
xlpr.sequenceNumber = client->sequence; xlpr.sequenceNumber = client->sequence;
WriteReplyToClient(client, sizeof(xGenericReply), &xlpr); WriteReplyToClient(client, sizeof(xGenericReply), &xlpr);
if (numProps) if (numProps)

View File

@ -731,7 +731,7 @@ SLHostsExtend(ClientPtr pClient, int size, char *buf)
int len = host->length; int len = host->length;
char n; char n;
swaps (&host->length, n); swaps (&host->length, n);
bufT += sizeof (xHostEntry) + (((len + 3) >> 2) << 2); bufT += sizeof (xHostEntry) + pad_to_int32(len);
} }
(void)WriteToClient (pClient, size, buf); (void)WriteToClient (pClient, size, buf);
} }
@ -1222,7 +1222,7 @@ SwapConnSetupInfo(
pInfoT += sizeof(xConnSetup); pInfoT += sizeof(xConnSetup);
/* Copy the vendor string */ /* Copy the vendor string */
i = (pConnSetup->nbytesVendor + 3) & ~3; i = pad_to_int32(pConnSetup->nbytesVendor);
memcpy(pInfoT, pInfo, i); memcpy(pInfoT, pInfo, i);
pInfo += i; pInfo += i;
pInfoT += i; pInfoT += i;

View File

@ -1457,8 +1457,8 @@ GetWindowAttributes(WindowPtr pWin, ClientPtr client, xGetWindowAttributesReply
wa->backingStore = NotUseful; wa->backingStore = NotUseful;
else else
wa->backingStore = pWin->backingStore; wa->backingStore = pWin->backingStore;
wa->length = (sizeof(xGetWindowAttributesReply) - wa->length = bytes_to_int32(sizeof(xGetWindowAttributesReply) -
sizeof(xGenericReply)) >> 2; sizeof(xGenericReply));
wa->sequenceNumber = client->sequence; wa->sequenceNumber = client->sequence;
wa->backingBitPlanes = wBackingBitPlanes (pWin); wa->backingBitPlanes = wBackingBitPlanes (pWin);
wa->backingPixel = wBackingPixel (pWin); wa->backingPixel = wBackingPixel (pWin);