File 71ab94418ead8f59c6124e8b3e53f8df7340f095.patch of Package xrandr

From 71ab94418ead8f59c6124e8b3e53f8df7340f095 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Mon, 18 Sep 2023 14:06:41 -0700
Subject: [PATCH] set_gamma_info: remove unnecessary round-trip to server

XRRGetCrtcGamma() returns the exact same size information as
XRRGetCrtcGammaSize(), so just use it instead of waiting for
the X server to send it an extra time.

(And if something has gone very wrong so that they aren't the same,
 this avoids out-of-bounds reads processing the returned gamma arrays
 by using the size of the arrays we allocated.)

Reported-by: Gregory James DUCK <gjduck@gmail.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
---
 xrandr.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/xrandr.c b/xrandr.c
index 95a9988..3750e42 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -1063,17 +1063,12 @@ set_gamma_info(output_t *output)
     if (!output->crtc_info)
 	return;
 
-    size = XRRGetCrtcGammaSize(dpy, output->crtc_info->crtc.xid);
-    if (!size) {
-	warning("Failed to get size of gamma for output %s\n", output->output.string);
-	return;
-    }
-
     crtc_gamma = XRRGetCrtcGamma(dpy, output->crtc_info->crtc.xid);
     if (!crtc_gamma) {
 	warning("Failed to get gamma for output %s\n", output->output.string);
 	return;
     }
+    size = crtc_gamma->size;
 
     /*
      * Here is a bit tricky because gamma is a whole curve for each
-- 
GitLab

openSUSE Build Service is sponsored by