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

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