From 286d83260216e8e53db701eed5c785aae1c716bf Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 29 Jun 2016 01:36:31 +0200 Subject: Use internal temp variable for swap macros. Make swaps/swapl type safe (introducing wrong_size check at build time). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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 Signed-off-by: Matt Turner commit 9edcae78c46286baff42e74bfe26f6ae4d00fe01 Author: Matt Turner 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 Signed-off-by: Matt Turner commit dab064fa5e0b1f5c67222562ad5367005832cba1 Author: Andrea Canciani 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 Reviewed-by: Soren Sandmann Reviewed-by: Julien Cristau Signed-off-by: Keith Packard commit 54770c980cd2b91a8377f975a58ed69def5cfa42 Author: Matt Turner Date: Tue Aug 16 16:59:07 2011 -0400 Cast char* buffers to swap functions Reviewed-by: Peter Harris Signed-off-by: Matt Turner commit 6844bd2e63490870bab3c469eec6030354ef2865 Author: Alan Coopersmith Date: Wed Jan 9 19:52:00 2008 -0800 More Xv extension byte swapping fixes commit e46f6ddeccd082b2d507a1e8b57ea30e6b0a2c83 Author: Michel Dänzer Date: Wed Jan 16 14:24:22 2008 +0100 Yet another Xv extension byte swapping fix. --- nx-X11/programs/Xserver/dbe/dbe.c | 63 ++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 38 deletions(-) (limited to 'nx-X11/programs/Xserver/dbe') diff --git a/nx-X11/programs/Xserver/dbe/dbe.c b/nx-X11/programs/Xserver/dbe/dbe.c index 5687f3d56..0525546a0 100644 --- a/nx-X11/programs/Xserver/dbe/dbe.c +++ b/nx-X11/programs/Xserver/dbe/dbe.c @@ -362,8 +362,6 @@ ProcDbeGetVersion(client) { /* REQUEST(xDbeGetVersionReq); */ xDbeGetVersionReply rep; - register int n; - REQUEST_SIZE_MATCH(xDbeGetVersionReq); @@ -375,7 +373,7 @@ ProcDbeGetVersion(client) if (client->swapped) { - swaps(&rep.sequenceNumber, n); + swaps(&rep.sequenceNumber); } WriteToClient(client, sizeof(xDbeGetVersionReply), (char *)&rep); @@ -898,7 +896,7 @@ ProcDbeGetVisualInfo(client) xDbeGetVisualInfoReply rep; Drawable *drawables; DrawablePtr *pDrawables = NULL; - register int i, j, n; + register int i, j; register int count; /* number of visual infos in reply */ register int length; /* length of reply */ ScreenPtr pScreen; @@ -984,9 +982,9 @@ ProcDbeGetVisualInfo(client) if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.m, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.m); } /* Send off reply. */ @@ -1003,7 +1001,7 @@ ProcDbeGetVisualInfo(client) if (client->swapped) { - swapl(&data32, n); + swapl(&data32); } WriteToClient(client, sizeof(CARD32), (char *)&data32); @@ -1024,7 +1022,7 @@ ProcDbeGetVisualInfo(client) if (client->swapped) { - swapl(&visInfo.visualID, n); + swapl(&visInfo.visualID); /* We do not need to swap depth and perfLevel since they are * already 1 byte quantities. @@ -1075,8 +1073,6 @@ ProcDbeGetBackBufferAttributes(client) REQUEST(xDbeGetBackBufferAttributesReq); xDbeGetBackBufferAttributesReply rep; DbeWindowPrivPtr pDbeWindowPriv; - int n; - REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq); @@ -1096,9 +1092,9 @@ ProcDbeGetBackBufferAttributes(client) if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.attributes, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.attributes); } WriteToClient(client, sizeof(xDbeGetBackBufferAttributesReply), @@ -1179,10 +1175,8 @@ SProcDbeGetVersion(client) ClientPtr client; { REQUEST(xDbeGetVersionReq); - register int n; - - swaps(&stuff->length, n); + swaps(&stuff->length); return(ProcDbeGetVersion(client)); } /* SProcDbeGetVersion() */ @@ -1216,13 +1210,12 @@ SProcDbeAllocateBackBufferName(client) ClientPtr client; { REQUEST(xDbeAllocateBackBufferNameReq); - register int n; - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq); - swapl(&stuff->window, n); - swapl(&stuff->buffer, n); + swapl(&stuff->window); + swapl(&stuff->buffer); /* stuff->swapAction is a byte. We do not need to swap this field. */ return(ProcDbeAllocateBackBufferName(client)); @@ -1252,13 +1245,11 @@ SProcDbeDeallocateBackBufferName(client) ClientPtr client; { REQUEST (xDbeDeallocateBackBufferNameReq); - register int n; - - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq); - swapl(&stuff->buffer, n); + swapl(&stuff->buffer); return(ProcDbeDeallocateBackBufferName(client)); @@ -1291,14 +1282,14 @@ SProcDbeSwapBuffers(client) ClientPtr client; { REQUEST(xDbeSwapBuffersReq); - unsigned int i, n; + unsigned int i; xDbeSwapInfo *pSwapInfo; - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq); - swapl(&stuff->n, n); + swapl(&stuff->n); if (stuff->n > UINT32_MAX / sizeof(DbeSwapInfoRec)) return BadAlloc; REQUEST_FIXED_SIZE(xDbeSwapBuffersReq, stuff->n * sizeof(xDbeSwapInfo)); @@ -1313,7 +1304,7 @@ SProcDbeSwapBuffers(client) */ for (i = 0; i < stuff->n; i++) { - swapl(&pSwapInfo->window, n); + swapl(&pSwapInfo->window); } } @@ -1343,9 +1334,8 @@ SProcDbeBeginIdiom(client) ClientPtr client; { REQUEST(xDbeBeginIdiomReq); - register int n; - swaps(&stuff->length, n); + swaps(&stuff->length); return(ProcDbeBeginIdiom(client)); } /* SProcDbeBeginIdiom() */ @@ -1373,13 +1363,11 @@ SProcDbeGetVisualInfo(client) ClientPtr client; { REQUEST(xDbeGetVisualInfoReq); - register int n; - - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq); - swapl(&stuff->n, n); + swapl(&stuff->n); SwapRestL(stuff); return(ProcDbeGetVisualInfo(client)); @@ -1408,12 +1396,11 @@ SProcDbeGetBackBufferAttributes(client) ClientPtr client; { REQUEST (xDbeGetBackBufferAttributesReq); - register int n; - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq); - swapl(&stuff->buffer, n); + swapl(&stuff->buffer); return(ProcDbeGetBackBufferAttributes(client)); -- cgit v1.2.3