From 1bcff3fe3592de416d09af97432578d9eb77eff6 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 15 Jul 2025 20:34:13 +0200 Subject: [PATCH] dbe: ProcDbeGetVisualInfo(): drop unncessary payload length computation Since using x_rpcbuf, we don't need extra computation of the payload_length, as the x_rpcbuf already knows the amount of data written into it. Signed-off-by: Enrico Weigelt, metux IT consult --- dbe/dbe.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/dbe/dbe.c b/dbe/dbe.c index b1f78f25b9..ad404359e5 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -561,12 +561,10 @@ ProcDbeGetVisualInfo(ClientPtr client) { REQUEST(xDbeGetVisualInfoReq); DbeScreenPrivPtr pDbeScreenPriv; - xDbeGetVisualInfoReply rep; Drawable *drawables; DrawablePtr *pDrawables = NULL; register int i, rc; register int count; /* number of visual infos in reply */ - register int length; /* length of reply */ ScreenPtr pScreen; XdbeScreenVisualInfo *pScrVisInfo; @@ -605,8 +603,6 @@ ProcDbeGetVisualInfo(ClientPtr client) return BadAlloc; } - length = 0; - for (i = 0; i < count; i++) { pScreen = (stuff->n == 0) ? screenInfo.screens[i] : pDrawables[i]->pScreen; @@ -623,25 +619,6 @@ ProcDbeGetVisualInfo(ClientPtr client) /* Free visinfos that we allocated for previous screen infos. */ goto clearRpcBuf; } - - /* Account for n, number of xDbeVisInfo items in list. */ - length += sizeof(CARD32); - - /* Account for n xDbeVisInfo items */ - length += pScrVisInfo[i].count * sizeof(xDbeVisInfo); - } - - rep = (xDbeGetVisualInfoReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = bytes_to_int32(length), - .m = count - }; - - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.m); } for (i = 0; i < count; i++) { @@ -666,6 +643,24 @@ ProcDbeGetVisualInfo(ClientPtr client) } } + if (rpcbuf.error) { + rc = BadAlloc; + goto clearRpcBuf; + } + + xDbeGetVisualInfoReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = bytes_to_int32(rpcbuf.wpos), + .m = count + }; + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.m); + } + rc = Success; WriteToClient(client, sizeof(xDbeGetVisualInfoReply), &rep); WriteRpcbufToClient(client, &rpcbuf);