Blame SOURCES/0001-record-Fix-out-of-bounds-access-in-SwapCreateRegiste.patch

b5718c
From acc50e6097d51fec0c6c34d84c35018a50c52d5a Mon Sep 17 00:00:00 2001
b5718c
From: Povilas Kanapickas <povilas@radix.lt>
b5718c
Date: Tue, 14 Dec 2021 15:00:00 +0200
b5718c
Subject: [PATCH xserver 1/4] record: Fix out of bounds access in
b5718c
 SwapCreateRegister()
b5718c
b5718c
ZDI-CAN-14952, CVE-2021-4011
b5718c
b5718c
This vulnerability was discovered and the fix was suggested by:
b5718c
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
b5718c
b5718c
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
b5718c
(cherry picked from commit e56f61c79fc3cee26d83cda0f84ae56d5979f768)
b5718c
---
b5718c
 record/record.c | 4 ++--
b5718c
 1 file changed, 2 insertions(+), 2 deletions(-)
b5718c
b5718c
diff --git a/record/record.c b/record/record.c
b5718c
index 05d751ac2..a8aec23bd 100644
b5718c
--- a/record/record.c
b5718c
+++ b/record/record.c
b5718c
@@ -2515,8 +2515,8 @@ SwapCreateRegister(ClientPtr client, xRecordRegisterClientsReq * stuff)
b5718c
         swapl(pClientID);
b5718c
     }
b5718c
     if (stuff->nRanges >
b5718c
-        client->req_len - bytes_to_int32(sz_xRecordRegisterClientsReq)
b5718c
-        - stuff->nClients)
b5718c
+        (client->req_len - bytes_to_int32(sz_xRecordRegisterClientsReq)
b5718c
+        - stuff->nClients) / bytes_to_int32(sz_xRecordRange))
b5718c
         return BadLength;
b5718c
     RecordSwapRanges((xRecordRange *) pClientID, stuff->nRanges);
b5718c
     return Success;
b5718c
-- 
b5718c
2.33.1
b5718c