aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/xfixes/cursor.c
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/xfixes/cursor.c
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/xfixes/cursor.c')
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/cursor.c111
1 files changed, 49 insertions, 62 deletions
diff --git a/nx-X11/programs/Xserver/xfixes/cursor.c b/nx-X11/programs/Xserver/xfixes/cursor.c
index c60d4b37c..29c6061d6 100755
--- a/nx-X11/programs/Xserver/xfixes/cursor.c
+++ b/nx-X11/programs/Xserver/xfixes/cursor.c
@@ -225,12 +225,11 @@ GetBit (unsigned char *line, int x)
int
SProcXFixesSelectCursorInput (ClientPtr client)
{
- register int n;
REQUEST(xXFixesSelectCursorInputReq);
- swaps(&stuff->length, n);
- swapl(&stuff->window, n);
- swapl(&stuff->eventMask, n);
+ swaps(&stuff->length);
+ swapl(&stuff->window);
+ swapl(&stuff->eventMask);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
@@ -329,20 +328,18 @@ ProcXFixesGetCursorImage (ClientPtr client)
rep->cursorSerial = pCursor->serialNumber;
image = (CARD32 *) (rep + 1);
- CopyCursorToImage (pCursor, image);
- if (client->swapped)
- {
- int n;
- swaps (&rep->sequenceNumber, n);
- swapl (&rep->length, n);
- swaps (&rep->x, n);
- swaps (&rep->y, n);
- swaps (&rep->width, n);
- swaps (&rep->height, n);
- swaps (&rep->xhot, n);
- swaps (&rep->yhot, n);
- swapl (&rep->cursorSerial, n);
- SwapLongs (image, npixels);
+ CopyCursorToImage(pCursor, image);
+ if (client->swapped) {
+ swaps(&rep->sequenceNumber);
+ swapl(&rep->length);
+ swaps(&rep->x);
+ swaps(&rep->y);
+ swaps(&rep->width);
+ swaps(&rep->height);
+ swaps(&rep->xhot);
+ swaps(&rep->yhot);
+ swapl(&rep->cursorSerial);
+ SwapLongs(image, npixels);
}
(void) WriteToClient(client, sizeof (xXFixesGetCursorImageReply) +
(npixels << 2), (char *) rep);
@@ -353,9 +350,8 @@ ProcXFixesGetCursorImage (ClientPtr client)
int
SProcXFixesGetCursorImage (ClientPtr client)
{
- int n;
REQUEST(xXFixesGetCursorImageReq);
- swaps (&stuff->length, n);
+ swaps(&stuff->length);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
@@ -381,13 +377,12 @@ ProcXFixesSetCursorName (ClientPtr client)
int
SProcXFixesSetCursorName (ClientPtr client)
{
- int n;
REQUEST(xXFixesSetCursorNameReq);
- swaps (&stuff->length, n);
+ swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
- swapl (&stuff->cursor, n);
- swaps (&stuff->nbytes, n);
+ swapl(&stuff->cursor);
+ swaps(&stuff->nbytes);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
@@ -413,13 +408,11 @@ ProcXFixesGetCursorName (ClientPtr client)
reply.sequenceNumber = client->sequence;
reply.atom = pCursor->name;
reply.nbytes = len;
- if (client->swapped)
- {
- int n;
- swaps (&reply.sequenceNumber, n);
- swapl (&reply.length, n);
- swapl (&reply.atom, n);
- swaps (&reply.nbytes, n);
+ if (client->swapped) {
+ swaps(&reply.sequenceNumber);
+ swapl(&reply.length);
+ swapl(&reply.atom);
+ swaps(&reply.nbytes);
}
WriteReplyToClient(client, sizeof(xXFixesGetCursorNameReply), &reply);
(void)WriteToClient(client, len, str);
@@ -430,12 +423,11 @@ ProcXFixesGetCursorName (ClientPtr client)
int
SProcXFixesGetCursorName (ClientPtr client)
{
- int n;
REQUEST(xXFixesSetCursorNameReq);
- swaps (&stuff->length, n);
+ swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
- swapl (&stuff->cursor, n);
+ swapl(&stuff->cursor);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
@@ -482,23 +474,21 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
rep->nbytes = nbytes;
image = (CARD32 *) (rep + 1);
- CopyCursorToImage (pCursor, image);
- memcpy ((image + npixels), name, nbytes);
- if (client->swapped)
- {
- int n;
- swaps (&rep->sequenceNumber, n);
- swapl (&rep->length, n);
- swaps (&rep->x, n);
- swaps (&rep->y, n);
- swaps (&rep->width, n);
- swaps (&rep->height, n);
- swaps (&rep->xhot, n);
- swaps (&rep->yhot, n);
- swapl (&rep->cursorSerial, n);
- swapl (&rep->cursorName, n);
- swaps (&rep->nbytes, n);
- SwapLongs (image, npixels);
+ CopyCursorToImage(pCursor, image);
+ memcpy((image + npixels), name, nbytes);
+ if (client->swapped) {
+ swaps(&rep->sequenceNumber);
+ swapl(&rep->length);
+ swaps(&rep->x);
+ swaps(&rep->y);
+ swaps(&rep->width);
+ swaps(&rep->height);
+ swaps(&rep->xhot);
+ swaps(&rep->yhot);
+ swapl(&rep->cursorSerial);
+ swapl(&rep->cursorName);
+ swaps(&rep->nbytes);
+ SwapLongs(image, npixels);
}
(void) WriteToClient(client, sizeof (xXFixesGetCursorImageAndNameReply) +
(npixels << 2) + nbytesRound, (char *) rep);
@@ -509,9 +499,8 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
int
SProcXFixesGetCursorImageAndName (ClientPtr client)
{
- int n;
REQUEST(xXFixesGetCursorImageAndNameReq);
- swaps (&stuff->length, n);
+ swaps(&stuff->length);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
@@ -642,13 +631,12 @@ ProcXFixesChangeCursor (ClientPtr client)
int
SProcXFixesChangeCursor (ClientPtr client)
{
- int n;
REQUEST(xXFixesChangeCursorReq);
- swaps (&stuff->length, n);
+ swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXFixesChangeCursorReq);
- swapl (&stuff->source, n);
- swapl (&stuff->destination, n);
+ swapl(&stuff->source);
+ swapl(&stuff->destination);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
@@ -678,13 +666,12 @@ ProcXFixesChangeCursorByName (ClientPtr client)
int
SProcXFixesChangeCursorByName (ClientPtr client)
{
- int n;
REQUEST(xXFixesChangeCursorByNameReq);
- swaps (&stuff->length, n);
- REQUEST_AT_LEAST_SIZE (xXFixesChangeCursorByNameReq);
- swapl (&stuff->source, n);
- swaps (&stuff->nbytes, n);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xXFixesChangeCursorByNameReq);
+ swapl(&stuff->source);
+ swaps(&stuff->nbytes);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}