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

7984e5
From 59c977bff66de77bd93ce8853e33e1b4ca661a49 Mon Sep 17 00:00:00 2001
7984e5
From: Povilas Kanapickas <povilas@radix.lt>
7984e5
Date: Tue, 14 Dec 2021 15:00:03 +0200
7984e5
Subject: [PATCH xserver 4/4] render: Fix out of bounds access in
7984e5
 SProcRenderCompositeGlyphs()
7984e5
7984e5
ZDI-CAN-14192, CVE-2021-4008
7984e5
7984e5
This vulnerability was discovered and the fix was suggested by:
7984e5
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
7984e5
7984e5
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
7984e5
(cherry picked from commit ebce7e2d80e7c80e1dda60f2f0bc886f1106ba60)
7984e5
---
7984e5
 render/render.c | 9 +++++++++
7984e5
 1 file changed, 9 insertions(+)
7984e5
7984e5
diff --git a/render/render.c b/render/render.c
7984e5
index c376090ca..456f156d4 100644
7984e5
--- a/render/render.c
7984e5
+++ b/render/render.c
7984e5
@@ -2309,6 +2309,9 @@ SProcRenderCompositeGlyphs(ClientPtr client)
7984e5
 
7984e5
         i = elt->len;
7984e5
         if (i == 0xff) {
7984e5
+            if (buffer + 4 > end) {
7984e5
+                return BadLength;
7984e5
+            }
7984e5
             swapl((int *) buffer);
7984e5
             buffer += 4;
7984e5
         }
7984e5
@@ -2319,12 +2322,18 @@ SProcRenderCompositeGlyphs(ClientPtr client)
7984e5
                 buffer += i;
7984e5
                 break;
7984e5
             case 2:
7984e5
+                if (buffer + i * 2 > end) {
7984e5
+                    return BadLength;
7984e5
+                }
7984e5
                 while (i--) {
7984e5
                     swaps((short *) buffer);
7984e5
                     buffer += 2;
7984e5
                 }
7984e5
                 break;
7984e5
             case 4:
7984e5
+                if (buffer + i * 4 > end) {
7984e5
+                    return BadLength;
7984e5
+                }
7984e5
                 while (i--) {
7984e5
                     swapl((int *) buffer);
7984e5
                     buffer += 4;
7984e5
-- 
7984e5
2.33.1
7984e5