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

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