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