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

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