diff --git a/dix/property.c b/dix/property.c index e5e579f95..aa131710a 100644 --- a/dix/property.c +++ b/dix/property.c @@ -421,22 +421,6 @@ DeleteAllWindowProperties(WindowPtr pWin) pWin->optional->userProps = NULL; } -static int -NullPropertyReply(ClientPtr client, ATOM propertyType, int format) -{ - xGetPropertyReply reply = { - .type = X_Reply, - .format = format, - .sequenceNumber = client->sequence, - .length = 0, - .propertyType = propertyType, - .bytesAfter = 0, - .nItems = 0 - }; - WriteReplyToClient(client, sizeof(xGenericReply), &reply); - return Success; -} - /***************** * GetProperty * If type Any is specified, returns the property from the specified @@ -454,7 +438,6 @@ ProcGetProperty(ClientPtr client) unsigned long n, len, ind; int rc; WindowPtr pWin; - xGetPropertyReply reply; Mask win_mode = DixGetPropAccess, prop_mode = DixReadAccess; REQUEST(xGetPropertyReq); @@ -483,8 +466,17 @@ ProcGetProperty(ClientPtr client) } rc = dixLookupProperty(&pProp, pWin, stuff->property, client, prop_mode); - if (rc == BadMatch) - return NullPropertyReply(client, None, 0); + if (rc == BadMatch) { + xGetPropertyReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + }; + if (client->swapped) { + swaps(&rep.sequenceNumber); + } + WriteToClient(client, sizeof(rep), &rep); + return Success; + } else if (rc != Success) return rc; @@ -493,16 +485,19 @@ ProcGetProperty(ClientPtr client) if (((stuff->type != pProp->type) && (stuff->type != AnyPropertyType)) ) { - reply = (xGetPropertyReply) { + xGetPropertyReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, .bytesAfter = pProp->size, .format = pProp->format, - .length = 0, - .nItems = 0, .propertyType = pProp->type }; - WriteReplyToClient(client, sizeof(xGenericReply), &reply); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.propertyType); + swapl(&rep.bytesAfter); + } + WriteToClient(client, sizeof(rep), &rep); return Success; } @@ -522,7 +517,7 @@ ProcGetProperty(ClientPtr client) len = min(n - ind, 4 * stuff->longLength); - reply = (xGetPropertyReply) { + xGetPropertyReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, .bytesAfter = n - (ind + len), @@ -532,26 +527,15 @@ ProcGetProperty(ClientPtr client) .propertyType = pProp->type }; - if (stuff->delete && (reply.bytesAfter == 0)) + if (stuff->delete && (rep.bytesAfter == 0)) deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp); - WriteReplyToClient(client, sizeof(xGenericReply), &reply); - if (len) { - switch (reply.format) { - case 32: - client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; - break; - case 16: - client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write; - break; - default: - client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient; - break; - } - WriteSwappedDataToClient(client, len, (char *) pProp->data + ind); - } + void *payload = calloc(1, len); + if (!payload) + return BadAlloc; + memcpy(payload, (char*)(pProp->data) + ind, len); - if (stuff->delete && (reply.bytesAfter == 0)) { + if (stuff->delete && (rep.bytesAfter == 0)) { /* Delete the Property */ if (pWin->optional->userProps == pProp) { /* Takes care of head */ @@ -569,6 +553,22 @@ ProcGetProperty(ClientPtr client) free(pProp->data); dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); } + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.propertyType); + swapl(&rep.bytesAfter); + swapl(&rep.nItems); + if (rep.format == 32) + SwapLongs(payload, len / 4); + else if (rep.format == 16) + SwapShorts(payload, len / 2); + } + + WriteToClient(client, sizeof(rep), &rep); + WriteToClient(client, len, payload); + free(payload); return Success; } diff --git a/dix/swaprep.c b/dix/swaprep.c index 3ee838cd1..a454abfd9 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -181,17 +181,6 @@ SGenericReply(ClientPtr pClient, int size, xGenericReply * pRep) WriteToClient(pClient, size, pRep); } -void _X_COLD -SGetPropertyReply(ClientPtr pClient, int size, xGetPropertyReply * pRep) -{ - swaps(&pRep->sequenceNumber); - swapl(&pRep->length); - swapl(&pRep->propertyType); - swapl(&pRep->bytesAfter); - swapl(&pRep->nItems); - WriteToClient(pClient, size, pRep); -} - void _X_COLD SListPropertiesReply(ClientPtr pClient, int size, xListPropertiesReply * pRep) { diff --git a/dix/tables.c b/dix/tables.c index 8cc2d5cdc..ed2794fe7 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -732,7 +732,7 @@ ReplySwapPtr ReplySwapVector[256] = { ReplyNotSwappd, ReplyNotSwappd, ReplyNotSwappd, - (ReplySwapPtr) SGetPropertyReply, /* 20 */ + ReplyNotSwappd, /* 20 */ (ReplySwapPtr) SListPropertiesReply, ReplyNotSwappd, ReplyNotSwappd, diff --git a/include/swaprep.h b/include/swaprep.h index 3981cd7c5..ec94b89a7 100644 --- a/include/swaprep.h +++ b/include/swaprep.h @@ -44,10 +44,6 @@ extern void SGenericReply(ClientPtr /* pClient */ , int /* size */ , xGenericReply * /* pRep */ ); -extern void SGetPropertyReply(ClientPtr /* pClient */ , - int /* size */ , - xGetPropertyReply * /* pRep */ ); - extern void SListPropertiesReply(ClientPtr /* pClient */ , int /* size */ , xListPropertiesReply * /* pRep */ );