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 | |||
@@ -1541,6 +1541,7 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client) | |||
1541 | { | 1541 | { |
1542 | CARD16 *ramp = NULL; | 1542 | CARD16 *ramp = NULL; |
1543 | int n, length, i; | 1543 | int n, length, i; |
1544 | size_t ramplen; | ||
1544 | xXF86VidModeGetGammaRampReply rep; | 1545 | xXF86VidModeGetGammaRampReply rep; |
1545 | REQUEST(xXF86VidModeGetGammaRampReq); | 1546 | REQUEST(xXF86VidModeGetGammaRampReq); |
1546 | 1547 | ||
@@ -1555,7 +1556,8 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client) | |||
1555 | length = (stuff->size + 1) & ~1; | 1556 | length = (stuff->size + 1) & ~1; |
1556 | 1557 | ||
1557 | if(stuff->size) { | 1558 | if(stuff->size) { |
1558 | if(!(ramp = xalloc(length * 3 * sizeof(CARD16)))) | 1559 | ramplen = length * 3 * sizeof(CARD16); |
1560 | if (!(ramp = xalloc(ramplen))) | ||
1559 | return BadAlloc; | 1561 | return BadAlloc; |
1560 | 1562 | ||
1561 | if (!VidModeGetGammaRamp(stuff->screen, stuff->size, | 1563 | if (!VidModeGetGammaRamp(stuff->screen, stuff->size, |
@@ -1573,13 +1575,12 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client) | |||
1573 | swaps(&rep.sequenceNumber, n); | 1575 | swaps(&rep.sequenceNumber, n); |
1574 | swapl(&rep.length, n); | 1576 | swapl(&rep.length, n); |
1575 | swaps(&rep.size, n); | 1577 | swaps(&rep.size, n); |
1576 | for(i = 0; i < length * 3; i++) | 1578 | SwapShorts(ramp, length * 3); |
1577 | swaps(&ramp[i],n); | ||
1578 | } | 1579 | } |
1579 | WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), (char *)&rep); | 1580 | WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), (char *)&rep); |
1580 | 1581 | ||
1581 | if(stuff->size) { | 1582 | if(stuff->size) { |
1582 | WriteToClient(client, rep.length << 2, (char*)ramp); | 1583 | WriteToClient(client, ramplen, (char*)ramp); |
1583 | xfree(ramp); | 1584 | xfree(ramp); |
1584 | } | 1585 | } |
1585 | 1586 | ||
@@ -2060,7 +2061,6 @@ SProcXF86VidModeGetGamma(ClientPtr client) | |||
2060 | static int | 2061 | static int |
2061 | SProcXF86VidModeSetGammaRamp(ClientPtr client) | 2062 | SProcXF86VidModeSetGammaRamp(ClientPtr client) |
2062 | { | 2063 | { |
2063 | CARD16 *ramp; | ||
2064 | int length, n; | 2064 | int length, n; |
2065 | REQUEST(xXF86VidModeSetGammaRampReq); | 2065 | REQUEST(xXF86VidModeSetGammaRampReq); |
2066 | swaps(&stuff->length, n); | 2066 | swaps(&stuff->length, n); |
@@ -2069,11 +2069,7 @@ SProcXF86VidModeSetGammaRamp(ClientPtr client) | |||
2069 | swaps(&stuff->screen, n); | 2069 | swaps(&stuff->screen, n); |
2070 | length = ((stuff->size + 1) & ~1) * 6; | 2070 | length = ((stuff->size + 1) & ~1) * 6; |
2071 | REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length); | 2071 | REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length); |
2072 | ramp = (CARD16*)&stuff[1]; | 2072 | SwapRestS(stuff); |
2073 | while(length--) { | ||
2074 | swaps(ramp, n); | ||
2075 | ramp++; | ||
2076 | } | ||
2077 | return ProcXF86VidModeSetGammaRamp(client); | 2073 | return ProcXF86VidModeSetGammaRamp(client); |
2078 | } | 2074 | } |
2079 | 2075 | ||