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

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