From f908421d43959a44ff940fd89fd0e35150cfe3f9 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Fri, 26 May 2023 15:10:01 +0800
Subject: [PATCH] xkb: proof GetCountedString against request length attacks

---
 xkb/xkb.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/xkb/xkb.c b/xkb/xkb.c
index aa98578..87b73df 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5138,6 +5138,11 @@ _GetCountedString(char **wire_inout, ClientPtr client, char **str)
     CARD16 len;
 
     wire = *wire_inout;
+
+    if (client->req_len < 
+        bytes_to_int32(wire + 2 - (char *) client->requestBuffer))
+        return BadValue;
+
     len = *(CARD16 *) wire;
     if (client->swapped) {
         swaps(&len);
-- 
2.20.1

