diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-04-23 08:42:38 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-04-24 00:23:50 -0700 |
commit | 7d0f7518c2235a9dc783029971259ddaada2db20 (patch) | |
tree | 73449f35e0d0181b78cb742c39a47aeaab28ff5a | |
parent | 932d6bcbb68194c5bdfeb336f700dc8b31529223 (diff) |
Fix byte swapping of XF86VidMode{Get,Set}GammaRamp
Fixes OpenSolaris Bug 8315:
Xorg segfaults when screensaver fades in cross-endian xdmcp session
<http://defect.opensolaris.org/bz/show_bug.cgi?id=8315>
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
-rw-r--r-- | hw/xfree86/dixmods/extmod/xf86vmode.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c index ea8089e94..10b9ed370 100644 --- a/hw/xfree86/dixmods/extmod/xf86vmode.c +++ b/hw/xfree86/dixmods/extmod/xf86vmode.c @@ -1538,12 +1538,13 @@ ProcXF86VidModeSetGammaRamp(ClientPtr client) static int ProcXF86VidModeGetGammaRamp(ClientPtr client) { CARD16 *ramp = NULL; int n, length, i; + size_t ramplen; xXF86VidModeGetGammaRampReply rep; REQUEST(xXF86VidModeGetGammaRampReq); if(stuff->screen >= screenInfo.numScreens) return BadValue; @@ -1552,13 +1553,14 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client) REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq); length = (stuff->size + 1) & ~1; if(stuff->size) { - if(!(ramp = xalloc(length * 3 * sizeof(CARD16)))) + ramplen = length * 3 * sizeof(CARD16); + if (!(ramp = xalloc(ramplen))) return BadAlloc; if (!VidModeGetGammaRamp(stuff->screen, stuff->size, ramp, ramp + length, ramp + (length * 2))) { xfree(ramp); return BadValue; @@ -1570,19 +1572,18 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client) rep.sequenceNumber = client->sequence; rep.size = stuff->size; if(client->swapped) { swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); swaps(&rep.size, n); - for(i = 0; i < length * 3; i++) - swaps(&ramp[i],n); + SwapShorts(ramp, length * 3); } WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), (char *)&rep); if(stuff->size) { - WriteToClient(client, rep.length << 2, (char*)ramp); + WriteToClient(client, ramplen, (char*)ramp); xfree(ramp); } return (client->noClientException); } @@ -2057,26 +2058,21 @@ SProcXF86VidModeGetGamma(ClientPtr client) return ProcXF86VidModeGetGamma(client); } static int SProcXF86VidModeSetGammaRamp(ClientPtr client) { - CARD16 *ramp; int length, n; REQUEST(xXF86VidModeSetGammaRampReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq); swaps(&stuff->size, n); swaps(&stuff->screen, n); length = ((stuff->size + 1) & ~1) * 6; REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length); - ramp = (CARD16*)&stuff[1]; - while(length--) { - swaps(ramp, n); - ramp++; - } + SwapRestS(stuff); return ProcXF86VidModeSetGammaRamp(client); } static int SProcXF86VidModeGetGammaRamp(ClientPtr client) { |