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

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