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

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