Blame SOURCES/0001-xkb-proof-GetCountedString-against-request-length-at.patch

002a41
From 11beef0b7f1ed290348e45618e5fa0d2bffcb72e Mon Sep 17 00:00:00 2001
002a41
From: Peter Hutterer <peter.hutterer@who-t.net>
002a41
Date: Tue, 5 Jul 2022 12:06:20 +1000
002a41
Subject: [PATCH xserver] xkb: proof GetCountedString against request length
002a41
 attacks
002a41
002a41
GetCountedString did a check for the whole string to be within the
002a41
request buffer but not for the initial 2 bytes that contain the length
002a41
field. A swapped client could send a malformed request to trigger a
002a41
swaps() on those bytes, writing into random memory.
002a41
002a41
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
002a41
---
002a41
 xkb/xkb.c | 5 +++++
002a41
 1 file changed, 5 insertions(+)
002a41
002a41
diff --git a/xkb/xkb.c b/xkb/xkb.c
002a41
index f42f59ef3..1841cff26 100644
002a41
--- a/xkb/xkb.c
002a41
+++ b/xkb/xkb.c
002a41
@@ -5137,6 +5137,11 @@ _GetCountedString(char **wire_inout, ClientPtr client, char **str)
002a41
     CARD16 len;
002a41
 
002a41
     wire = *wire_inout;
002a41
+
002a41
+    if (client->req_len <
002a41
+        bytes_to_int32(wire + 2 - (char *) client->requestBuffer))
002a41
+        return BadValue;
002a41
+
002a41
     len = *(CARD16 *) wire;
002a41
     if (client->swapped) {
002a41
         swaps(&len;;
002a41
-- 
002a41
2.38.1
002a41