From 7539bdb82995cb5aa960635c3d9acfdb04cff22c Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 16 Jul 2025 04:47:07 +0200 Subject: [PATCH] xcmisc: ProcXCMiscGetXIDList(): use x_rpcbuf for payload assembly Use x_rpcbuf for reply payload assembly, instead of pre-counting and pre-allocating buffer. Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/xcmisc.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c index 81ac44f160..2b19553de8 100644 --- a/Xext/xcmisc.c +++ b/Xext/xcmisc.c @@ -33,7 +33,9 @@ from The Open Group. #include #include +#include "dix/dix_priv.h" #include "dix/resource_priv.h" +#include "dix/rpcbuf_priv.h" #include "miext/extinit_priv.h" #include "misc.h" @@ -106,6 +108,15 @@ ProcXCMiscGetXIDList(ClientPtr client) return BadAlloc; } count = GetXIDList(client, stuff->count, pids); + + struct x_rpcbuf rpcbuf = { .swapped = client->swapped, .err_clear = TRUE }; + + x_rpcbuf_write_CARD32s(&rpcbuf, pids, count); + free(pids); + + if (rpcbuf.error) + return BadAlloc; + rep = (xXCMiscGetXIDListReply) { .type = X_Reply, .sequenceNumber = client->sequence, @@ -117,12 +128,9 @@ ProcXCMiscGetXIDList(ClientPtr client) swapl(&rep.length); swapl(&rep.count); } + WriteToClient(client, sizeof(xXCMiscGetXIDListReply), &rep); - if (count) { - client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; - WriteSwappedDataToClient(client, count * sizeof(XID), pids); - } - free(pids); + WriteRpcbufToClient(client, &rpcbuf); return Success; }