Blame SOURCES/0004-render-Fix-out-of-bounds-access-in-SProcRenderCompos.patch

b5718c
From 35b4681c79480d980bd8dcba390146aad7817c47 Mon Sep 17 00:00:00 2001
b5718c
From: Povilas Kanapickas <povilas@radix.lt>
b5718c
Date: Tue, 14 Dec 2021 15:00:03 +0200
b5718c
Subject: [PATCH xserver 4/4] render: Fix out of bounds access in
b5718c
 SProcRenderCompositeGlyphs()
b5718c
b5718c
ZDI-CAN-14192, CVE-2021-4008
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 ebce7e2d80e7c80e1dda60f2f0bc886f1106ba60)
b5718c
---
b5718c
 render/render.c | 9 +++++++++
b5718c
 1 file changed, 9 insertions(+)
b5718c
b5718c
diff --git a/render/render.c b/render/render.c
b5718c
index c376090ca..456f156d4 100644
b5718c
--- a/render/render.c
b5718c
+++ b/render/render.c
b5718c
@@ -2309,6 +2309,9 @@ SProcRenderCompositeGlyphs(ClientPtr client)
b5718c
 
b5718c
         i = elt->len;
b5718c
         if (i == 0xff) {
b5718c
+            if (buffer + 4 > end) {
b5718c
+                return BadLength;
b5718c
+            }
b5718c
             swapl((int *) buffer);
b5718c
             buffer += 4;
b5718c
         }
b5718c
@@ -2319,12 +2322,18 @@ SProcRenderCompositeGlyphs(ClientPtr client)
b5718c
                 buffer += i;
b5718c
                 break;
b5718c
             case 2:
b5718c
+                if (buffer + i * 2 > end) {
b5718c
+                    return BadLength;
b5718c
+                }
b5718c
                 while (i--) {
b5718c
                     swaps((short *) buffer);
b5718c
                     buffer += 2;
b5718c
                 }
b5718c
                 break;
b5718c
             case 4:
b5718c
+                if (buffer + i * 4 > end) {
b5718c
+                    return BadLength;
b5718c
+                }
b5718c
                 while (i--) {
b5718c
                     swapl((int *) buffer);
b5718c
                     buffer += 4;
b5718c
-- 
b5718c
2.33.1
b5718c