aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/record
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-06-29 01:36:31 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-07-04 16:36:59 +0200
commit286d83260216e8e53db701eed5c785aae1c716bf (patch)
tree3b27e6dd17a7d4d00266819545ae97defa11cf81 /nx-X11/programs/Xserver/record
parentd1d859dfdec4b4665e06401383ab71926e4e731c (diff)
downloadnx-libs-286d83260216e8e53db701eed5c785aae1c716bf.tar.gz
nx-libs-286d83260216e8e53db701eed5c785aae1c716bf.tar.bz2
nx-libs-286d83260216e8e53db701eed5c785aae1c716bf.zip
Use internal temp variable for swap macros. Make swaps/swapl type safe (introducing wrong_size check at build time).
While working on this changeset, various spots got discovered where swapl or swaps was used on a wrong type, where byte swapping calls had been forgotten or done on the wrong variable. This backport at least includes changes from the following X.org commits, listed in non-chronological order: commit 2c7c520cfe0df30f4bc3adba59d9c62582823bf8 Author: Matt Turner <mattst88@gmail.com> Date: Thu Aug 4 15:35:41 2011 -0400 Use internal temp variable for swap macros Also, fix whitespace, mainly around swaps(&rep.sequenceNumber) Reviewed-by: Peter Harris <pharris@opentext.com> Signed-off-by: Matt Turner <mattst88@gmail.com> commit 9edcae78c46286baff42e74bfe26f6ae4d00fe01 Author: Matt Turner <mattst88@gmail.com> Date: Wed Sep 21 17:14:16 2011 -0400 Use correct swap{l,s} (or none at all for CARD8) Swapping the wrong size was never caught because swap{l,s} are macros. It's clear in the case of Xext/xres.c, that the author believed client_major/minor to be CARD16 from looking at the code in the first hunk. v2: dmx.c fixes from Keith. Reviewed-by: Peter Harris <pharris@opentext.com> Signed-off-by: Matt Turner <mattst88@gmail.com> commit dab064fa5e0b1f5c67222562ad5367005832cba1 Author: Andrea Canciani <ranma42@gmail.com> Date: Tue Nov 2 20:10:32 2010 +0100 render: Fix byteswapping of gradient stops The function swapStops repeatedly swaps the color components as CARD16, but incorrectly steps over them as if they were CARD32. This causes half of the stops not to be swapped at all and some unrelated data be swapped instead. Signed-off-by: Andrea Canciani <ranma42@gmail.com> Reviewed-by: Soren Sandmann <sandmann@daimi.au.dk> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Keith Packard <keithp@keithp.com> commit 54770c980cd2b91a8377f975a58ed69def5cfa42 Author: Matt Turner <mattst88@gmail.com> Date: Tue Aug 16 16:59:07 2011 -0400 Cast char* buffers to swap functions Reviewed-by: Peter Harris <pharris@opentext.com> Signed-off-by: Matt Turner <mattst88@gmail.com> commit 6844bd2e63490870bab3c469eec6030354ef2865 Author: Alan Coopersmith <alan.coopersmith@sun.com> Date: Wed Jan 9 19:52:00 2008 -0800 More Xv extension byte swapping fixes commit e46f6ddeccd082b2d507a1e8b57ea30e6b0a2c83 Author: Michel Dänzer <michel@tungstengraphics.com> Date: Wed Jan 16 14:24:22 2008 +0100 Yet another Xv extension byte swapping fix.
Diffstat (limited to 'nx-X11/programs/Xserver/record')
-rw-r--r--nx-X11/programs/Xserver/record/record.c98
1 files changed, 42 insertions, 56 deletions
diff --git a/nx-X11/programs/Xserver/record/record.c b/nx-X11/programs/Xserver/record/record.c
index 410920d02..9d549bb5c 100644
--- a/nx-X11/programs/Xserver/record/record.c
+++ b/nx-X11/programs/Xserver/record/record.c
@@ -297,7 +297,6 @@ RecordAProtocolElement(RecordContextPtr pContext, ClientPtr pClient,
CARD32 elemHeaderData[2];
int numElemHeaders = 0;
Bool recordingClientSwapped = pContext->pRecordingClient->swapped;
- int n;
CARD32 serverTime = 0;
Bool gotServerTime = FALSE;
int replylen;
@@ -341,11 +340,11 @@ RecordAProtocolElement(RecordContextPtr pContext, ClientPtr pClient,
if (recordingClientSwapped)
{
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swapl(&pRep->idBase, n);
- swapl(&pRep->serverTime, n);
- swapl(&pRep->recordedSequenceNumber, n);
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swapl(&pRep->idBase);
+ swapl(&pRep->serverTime);
+ swapl(&pRep->recordedSequenceNumber);
}
pContext->numBufBytes = SIZEOF(xRecordEnableContextReply);
}
@@ -363,7 +362,7 @@ RecordAProtocolElement(RecordContextPtr pContext, ClientPtr pClient,
else
elemHeaderData[numElemHeaders] = GetTimeInMillis();
if (recordingClientSwapped)
- swapl(&elemHeaderData[numElemHeaders], n);
+ swapl(&elemHeaderData[numElemHeaders]);
numElemHeaders++;
}
@@ -373,16 +372,16 @@ RecordAProtocolElement(RecordContextPtr pContext, ClientPtr pClient,
{
elemHeaderData[numElemHeaders] = pClient->sequence;
if (recordingClientSwapped)
- swapl(&elemHeaderData[numElemHeaders], n);
+ swapl(&elemHeaderData[numElemHeaders]);
numElemHeaders++;
}
/* adjust reply length */
replylen = pRep->length;
- if (recordingClientSwapped) swapl(&replylen, n);
+ if (recordingClientSwapped) swapl(&replylen);
replylen += numElemHeaders + (datalen >> 2) + (futurelen >> 2);
- if (recordingClientSwapped) swapl(&replylen, n);
+ if (recordingClientSwapped) swapl(&replylen);
pRep->length = replylen;
} /* end if not continued reply */
@@ -477,7 +476,6 @@ RecordABigRequest(pContext, client, stuff)
xReq *stuff;
{
CARD32 bigLength;
- char n;
int bytesLeft;
/* note: client->req_len has been frobbed by ReadRequestFromClient
@@ -494,7 +492,7 @@ RecordABigRequest(pContext, client, stuff)
/* reinsert the extended length field that was squished out */
bigLength = client->req_len + (sizeof(bigLength) >> 2);
if (client->swapped)
- swapl(&bigLength, n);
+ swapl(&bigLength);
RecordAProtocolElement(pContext, client, XRecordFromClient,
(void *)&bigLength, sizeof(bigLength), /* continuation */ -1);
bytesLeft -= sizeof(bigLength);
@@ -1998,7 +1996,6 @@ ProcRecordQueryVersion(client)
{
/* REQUEST(xRecordQueryVersionReq); */
xRecordQueryVersionReply rep;
- int n;
REQUEST_SIZE_MATCH(xRecordQueryVersionReq);
rep.type = X_Reply;
@@ -2008,9 +2005,9 @@ ProcRecordQueryVersion(client)
rep.minorVersion = SERVER_RECORD_MINOR_VERSION;
if(client->swapped)
{
- swaps(&rep.sequenceNumber, n);
- swaps(&rep.majorVersion, n);
- swaps(&rep.minorVersion, n);
+ swaps(&rep.sequenceNumber);
+ swaps(&rep.majorVersion);
+ swaps(&rep.minorVersion);
}
(void)WriteToClient(client, sizeof(xRecordQueryVersionReply),
(char *)&rep);
@@ -2320,13 +2317,12 @@ RecordSwapRanges(pRanges, nRanges)
int nRanges;
{
int i;
- register char n;
for (i = 0; i < nRanges; i++, pRanges++)
{
- swaps(&pRanges->extRequestsMinorFirst, n);
- swaps(&pRanges->extRequestsMinorLast, n);
- swaps(&pRanges->extRepliesMinorFirst, n);
- swaps(&pRanges->extRepliesMinorLast, n);
+ swaps(&pRanges->extRequestsMinorFirst);
+ swaps(&pRanges->extRequestsMinorLast);
+ swaps(&pRanges->extRepliesMinorFirst);
+ swaps(&pRanges->extRepliesMinorLast);
}
} /* RecordSwapRanges */
@@ -2338,7 +2334,6 @@ ProcRecordGetContext(client)
RecordContextPtr pContext;
REQUEST(xRecordGetContextReq);
xRecordGetContextReply rep;
- int n;
RecordClientsAndProtocolPtr pRCAP;
int nRCAPs = 0;
GetContextRangeInfoPtr pRangeInfo;
@@ -2437,9 +2432,9 @@ ProcRecordGetContext(client)
rep.elementHeader = pContext->elemHeaders;
if(client->swapped)
{
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.nClients, n);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.nClients);
}
(void)WriteToClient(client, sizeof(xRecordGetContextReply),
(char *)&rep);
@@ -2454,13 +2449,13 @@ ProcRecordGetContext(client)
rci.nRanges = pri->nRanges;
if (client->swapped)
{
- swapl(&rci.nRanges, n);
+ swapl(&rci.nRanges);
RecordSwapRanges(pri->pRanges, pri->nRanges);
}
for (i = 0; i < pRCAP->numClients; i++)
{
rci.clientResource = pRCAP->pClientIDs[i];
- if (client->swapped) swapl(&rci.clientResource, n);
+ if (client->swapped) swapl(&rci.clientResource);
WriteToClient(client, sizeof(xRecordClientInfo), (char *)&rci);
WriteToClient(client, sizeof(xRecordRange) * pri->nRanges,
(char *)pri->pRanges);
@@ -2712,12 +2707,11 @@ SProcRecordQueryVersion(client)
ClientPtr client;
{
REQUEST(xRecordQueryVersionReq);
- register char n;
- swaps(&stuff->length, n);
+ swaps(&stuff->length);
REQUEST_SIZE_MATCH(xRecordQueryVersionReq);
- swaps(&stuff->majorVersion, n);
- swaps(&stuff->minorVersion,n);
+ swaps(&stuff->majorVersion);
+ swaps(&stuff->minorVersion);
return ProcRecordQueryVersion(client);
} /* SProcRecordQueryVersion */
@@ -2725,19 +2719,18 @@ SProcRecordQueryVersion(client)
static int
SwapCreateRegister(xRecordRegisterClientsReq *stuff)
{
- register char n;
int i;
XID *pClientID;
- swapl(&stuff->context, n);
- swapl(&stuff->nClients, n);
- swapl(&stuff->nRanges, n);
+ swapl(&stuff->context);
+ swapl(&stuff->nClients);
+ swapl(&stuff->nRanges);
pClientID = (XID *)&stuff[1];
if (stuff->nClients > stuff->length - (sz_xRecordRegisterClientsReq >> 2))
return BadLength;
for (i = 0; i < stuff->nClients; i++, pClientID++)
{
- swapl(pClientID, n);
+ swapl(pClientID);
}
if (stuff->nRanges > stuff->length - (sz_xRecordRegisterClientsReq >> 2)
- stuff->nClients)
@@ -2753,9 +2746,8 @@ SProcRecordCreateContext(client)
{
REQUEST(xRecordCreateContextReq);
int status;
- register char n;
- swaps(&stuff->length, n);
+ swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xRecordCreateContextReq);
if ((status = SwapCreateRegister((void *)stuff)) != Success)
return status;
@@ -2769,9 +2761,8 @@ SProcRecordRegisterClients(client)
{
REQUEST(xRecordRegisterClientsReq);
int status;
- register char n;
- swaps(&stuff->length, n);
+ swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xRecordRegisterClientsReq);
if ((status = SwapCreateRegister((void *)stuff)) != Success)
return status;
@@ -2784,12 +2775,11 @@ SProcRecordUnregisterClients(client)
ClientPtr client;
{
REQUEST(xRecordUnregisterClientsReq);
- register char n;
- swaps(&stuff->length, n);
+ swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xRecordUnregisterClientsReq);
- swapl(&stuff->context, n);
- swapl(&stuff->nClients, n);
+ swapl(&stuff->context);
+ swapl(&stuff->nClients);
SwapRestL(stuff);
return ProcRecordUnregisterClients(client);
} /* SProcRecordUnregisterClients */
@@ -2800,11 +2790,10 @@ SProcRecordGetContext(client)
ClientPtr client;
{
REQUEST(xRecordGetContextReq);
- register char n;
- swaps(&stuff->length, n);
+ swaps(&stuff->length);
REQUEST_SIZE_MATCH(xRecordGetContextReq);
- swapl(&stuff->context, n);
+ swapl(&stuff->context);
return ProcRecordGetContext(client);
} /* SProcRecordGetContext */
@@ -2813,11 +2802,10 @@ SProcRecordEnableContext(client)
ClientPtr client;
{
REQUEST(xRecordEnableContextReq);
- register char n;
- swaps(&stuff->length, n);
+ swaps(&stuff->length);
REQUEST_SIZE_MATCH(xRecordEnableContextReq);
- swapl(&stuff->context, n);
+ swapl(&stuff->context);
return ProcRecordEnableContext(client);
} /* SProcRecordEnableContext */
@@ -2827,11 +2815,10 @@ SProcRecordDisableContext(client)
ClientPtr client;
{
REQUEST(xRecordDisableContextReq);
- register char n;
- swaps(&stuff->length, n);
+ swaps(&stuff->length);
REQUEST_SIZE_MATCH(xRecordDisableContextReq);
- swapl(&stuff->context, n);
+ swapl(&stuff->context);
return ProcRecordDisableContext(client);
} /* SProcRecordDisableContext */
@@ -2841,11 +2828,10 @@ SProcRecordFreeContext(client)
ClientPtr client;
{
REQUEST(xRecordFreeContextReq);
- register char n;
- swaps(&stuff->length, n);
+ swaps(&stuff->length);
REQUEST_SIZE_MATCH(xRecordFreeContextReq);
- swapl(&stuff->context, n);
+ swapl(&stuff->context);
return ProcRecordFreeContext(client);
} /* SProcRecordFreeContext */