Blame SOURCES/libvncserver-0.9.11-libvncclient-cursor-limit-width-height-input-values.patch

72bcc1
From 54220248886b5001fbbb9fa73c4e1a2cb9413fed Mon Sep 17 00:00:00 2001
72bcc1
From: Christian Beier <dontmind@freeshell.org>
72bcc1
Date: Sun, 17 Nov 2019 17:18:35 +0100
72bcc1
Subject: [PATCH] libvncclient/cursor: limit width/height input values
72bcc1
MIME-Version: 1.0
72bcc1
Content-Type: text/plain; charset=UTF-8
72bcc1
Content-Transfer-Encoding: 8bit
72bcc1
72bcc1
Avoids a possible heap overflow reported by Pavel Cheremushkin
72bcc1
<Pavel.Cheremushkin@kaspersky.com>.
72bcc1
72bcc1
re #275
72bcc1
72bcc1
Signed-off-by: Petr Písař <ppisar@redhat.com>
72bcc1
---
72bcc1
 libvncclient/cursor.c | 5 +++++
72bcc1
 1 file changed, 5 insertions(+)
72bcc1
72bcc1
diff --git a/libvncclient/cursor.c b/libvncclient/cursor.c
72bcc1
index 67f45726..40ffb3b0 100644
72bcc1
--- a/libvncclient/cursor.c
72bcc1
+++ b/libvncclient/cursor.c
72bcc1
@@ -28,6 +28,8 @@
72bcc1
 #define OPER_SAVE     0
72bcc1
 #define OPER_RESTORE  1
72bcc1
 
72bcc1
+#define MAX_CURSOR_SIZE 1024
72bcc1
+
72bcc1
 #define RGB24_TO_PIXEL(bpp,r,g,b)                                       \
72bcc1
    ((((uint##bpp##_t)(r) & 0xFF) * client->format.redMax + 127) / 255             \
72bcc1
     << client->format.redShift |                                              \
72bcc1
@@ -54,6 +56,9 @@ rfbBool HandleCursorShape(rfbClient* client,int xhot, int yhot, int width, int h
72bcc1
   if (width * height == 0)
72bcc1
     return TRUE;
72bcc1
 
72bcc1
+  if (width >= MAX_CURSOR_SIZE || height >= MAX_CURSOR_SIZE)
72bcc1
+    return FALSE;
72bcc1
+
72bcc1
   /* Allocate memory for pixel data and temporary mask data. */
72bcc1
   if(client->rcSource)
72bcc1
     free(client->rcSource);
72bcc1
-- 
72bcc1
2.21.1
72bcc1