From 81a79e9f8b32918c8ee302aec059a7f14bbc2b36 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 16 Jul 2025 12:57:48 +0200 Subject: [PATCH] panoramiX: ProcXineramaQueryScreens(): write out payload in one block Collect payload pieces into x_rpcbuf, so it can be written out once. Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/panoramiX.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index cdcff3ecc7..32469d89f1 100644 --- a/Xext/panoramiX.c +++ b/Xext/panoramiX.c @@ -33,6 +33,7 @@ Equipment Corporation. #include "dix/dix_priv.h" #include "dix/resource_priv.h" +#include "dix/rpcbuf_priv.h" #include "dix/screen_hooks_priv.h" #include "miext/extinit_priv.h" #include "Xext/panoramiX.h" @@ -1064,28 +1065,26 @@ ProcXineramaQueryScreens(ClientPtr client) swapl(&rep.length); swapl(&rep.number); } - WriteToClient(client, sizeof(xXineramaQueryScreensReply), &rep); + + x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE }; if (!noPanoramiXExtension) { - xXineramaScreenInfo scratch; int i; - FOR_NSCREENS_BACKWARD(i) { - scratch.x_org = screenInfo.screens[i]->x; - scratch.y_org = screenInfo.screens[i]->y; - scratch.width = screenInfo.screens[i]->width; - scratch.height = screenInfo.screens[i]->height; - - if (client->swapped) { - swaps(&scratch.x_org); - swaps(&scratch.y_org); - swaps(&scratch.width); - swaps(&scratch.height); - } - WriteToClient(client, sz_XineramaScreenInfo, &scratch); + xXineramaScreenInfo scratch = { + .x_org = screenInfo.screens[i]->x, + .y_org = screenInfo.screens[i]->y, + .width = screenInfo.screens[i]->width, + .height = screenInfo.screens[i]->height, + }; + /* scratch consists of 4x CARD16 */ + if (!x_rpcbuf_write_CARD16s(&rpcbuf, (CARD16*)&scratch, 4)) + return BadAlloc; } } + WriteToClient(client, sizeof(xXineramaQueryScreensReply), &rep); + WriteRpcbufToClient(client, &rpcbuf); return Success; }