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

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