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

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