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

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