mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2025-12-27 10:30:10 +01:00
XQuartz: appledri: Fix byte swapping in replies
Even though it's only valid when local, it is possible for a local client and the server to not match endianness, such as when running a ppc application under Rosetta. Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com> Reviewed-by: Jamey Sharp <jamey@minilop.net> (cherry picked from commit14205ade0c) Conflicts: hw/xquartz/xpr/appledri.c Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com> (cherry picked from commit0ad049706d)
This commit is contained in:
parent
1987c90aa4
commit
d9e2718220
1 changed files with 41 additions and 4 deletions
|
|
@ -91,7 +91,6 @@ ProcAppleDRIQueryVersion(
|
|||
)
|
||||
{
|
||||
xAppleDRIQueryVersionReply rep;
|
||||
register int n;
|
||||
|
||||
REQUEST_SIZE_MATCH(xAppleDRIQueryVersionReq);
|
||||
rep.type = X_Reply;
|
||||
|
|
@ -101,8 +100,12 @@ ProcAppleDRIQueryVersion(
|
|||
rep.minorVersion = SERVER_APPLEDRI_MINOR_VERSION;
|
||||
rep.patchVersion = SERVER_APPLEDRI_PATCH_VERSION;
|
||||
if (client->swapped) {
|
||||
register int n;
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swaps(&rep.majorVersion, n);
|
||||
swaps(&rep.minorVersion, n);
|
||||
swapl(&rep.patchVersion, n);
|
||||
}
|
||||
WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep);
|
||||
return Success;
|
||||
|
|
@ -134,6 +137,12 @@ ProcAppleDRIQueryDirectRenderingCapable(
|
|||
if (!LocalClient(client))
|
||||
rep.isCapable = 0;
|
||||
|
||||
if (client->swapped) {
|
||||
register int n;
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
}
|
||||
|
||||
WriteToClient(client,
|
||||
sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep);
|
||||
return Success;
|
||||
|
|
@ -158,6 +167,14 @@ ProcAppleDRIAuthConnection(
|
|||
ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic);
|
||||
rep.authenticated = 0;
|
||||
}
|
||||
|
||||
if (client->swapped) {
|
||||
register int n;
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.authenticated, n); /* Yes, this is a CARD32 ... sigh */
|
||||
}
|
||||
|
||||
WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep);
|
||||
return Success;
|
||||
}
|
||||
|
|
@ -217,6 +234,15 @@ ProcAppleDRICreateSurface(
|
|||
rep.key_1 = key[1];
|
||||
rep.uid = sid;
|
||||
|
||||
if (client->swapped) {
|
||||
register int n;
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.key_0, n);
|
||||
swapl(&rep.key_1, n);
|
||||
swapl(&rep.uid, n);
|
||||
}
|
||||
|
||||
WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep);
|
||||
return Success;
|
||||
}
|
||||
|
|
@ -278,7 +304,6 @@ ProcAppleDRICreatePixmap(ClientPtr client)
|
|||
|
||||
rep.stringLength = strlen(path) + 1;
|
||||
|
||||
/* No need for swapping, because this only runs if LocalClient is true. */
|
||||
rep.type = X_Reply;
|
||||
rep.length = bytes_to_int32(rep.stringLength);
|
||||
rep.sequenceNumber = client->sequence;
|
||||
|
|
@ -291,8 +316,20 @@ ProcAppleDRICreatePixmap(ClientPtr client)
|
|||
if(sizeof(rep) != sz_xAppleDRICreatePixmapReply)
|
||||
ErrorF("error sizeof(rep) is %zu\n", sizeof(rep));
|
||||
|
||||
WriteReplyToClient(client, sizeof(rep), &rep);
|
||||
(void)WriteToClient(client, rep.stringLength, path);
|
||||
if (client->swapped) {
|
||||
register int n;
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
swapl(&rep.length, n);
|
||||
swapl(&rep.stringLength, n);
|
||||
swapl(&rep.width, n);
|
||||
swapl(&rep.height, n);
|
||||
swapl(&rep.pitch, n);
|
||||
swapl(&rep.bpp, n);
|
||||
swapl(&rep.size, n);
|
||||
}
|
||||
|
||||
WriteToClient(client, sizeof(rep), &rep);
|
||||
WriteToClient(client, rep.stringLength, path);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue