Blame SOURCES/0002-Xi-ProcXIPassiveGrabDevice-needs-to-use-unswapped-le.patch

191e41
From 3e77295f888c67fc7645db5d0c00926a29ffecee Mon Sep 17 00:00:00 2001
191e41
From: Alan Coopersmith <alan.coopersmith@oracle.com>
191e41
Date: Fri, 22 Mar 2024 18:56:27 -0700
191e41
Subject: [PATCH 2/4] Xi: ProcXIPassiveGrabDevice needs to use unswapped length
191e41
 to send reply
191e41
191e41
CVE-2024-31081
191e41
191e41
Fixes: d220d6907 ("Xi: add GrabButton and GrabKeysym code.")
191e41
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
191e41
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1463>
191e41
---
191e41
 Xi/xipassivegrab.c | 5 ++++-
191e41
 1 file changed, 4 insertions(+), 1 deletion(-)
191e41
191e41
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
191e41
index c9ac2f855..896233bec 100644
191e41
--- a/Xi/xipassivegrab.c
191e41
+++ b/Xi/xipassivegrab.c
191e41
@@ -93,6 +93,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
191e41
     GrabParameters param;
191e41
     void *tmp;
191e41
     int mask_len;
191e41
+    uint32_t length;
191e41
 
191e41
     REQUEST(xXIPassiveGrabDeviceReq);
191e41
     REQUEST_FIXED_SIZE(xXIPassiveGrabDeviceReq,
191e41
@@ -247,9 +248,11 @@ ProcXIPassiveGrabDevice(ClientPtr client)
191e41
         }
191e41
     }
191e41
 
191e41
+    /* save the value before SRepXIPassiveGrabDevice swaps it */
191e41
+    length = rep.length;
191e41
     WriteReplyToClient(client, sizeof(rep), &rep;;
191e41
     if (rep.num_modifiers)
191e41
-        WriteToClient(client, rep.length * 4, modifiers_failed);
191e41
+        WriteToClient(client, length * 4, modifiers_failed);
191e41
 
191e41
  out:
191e41
     free(modifiers_failed);
191e41
-- 
191e41
2.44.0
191e41