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

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