2
1

0006-libvncclient-cursor-limit-width-height-input-values.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From 54220248886b5001fbbb9fa73c4e1a2cb9413fed Mon Sep 17 00:00:00 2001
  2. From: Christian Beier <dontmind@freeshell.org>
  3. Date: Sun, 17 Nov 2019 17:18:35 +0100
  4. Subject: [PATCH] libvncclient/cursor: limit width/height input values
  5. Avoids a possible heap overflow reported by Pavel Cheremushkin
  6. <Pavel.Cheremushkin@kaspersky.com>.
  7. re #275
  8. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  9. [Retrieved from:
  10. https://github.com/LibVNC/libvncserver/commit/54220248886b5001fbbb9fa73c4e1a2cb9413fed]
  11. ---
  12. libvncclient/cursor.c | 5 +++++
  13. 1 file changed, 5 insertions(+)
  14. diff --git a/libvncclient/cursor.c b/libvncclient/cursor.c
  15. index 67f45726..40ffb3b0 100644
  16. --- a/libvncclient/cursor.c
  17. +++ b/libvncclient/cursor.c
  18. @@ -28,6 +28,8 @@
  19. #define OPER_SAVE 0
  20. #define OPER_RESTORE 1
  21. +#define MAX_CURSOR_SIZE 1024
  22. +
  23. #define RGB24_TO_PIXEL(bpp,r,g,b) \
  24. ((((uint##bpp##_t)(r) & 0xFF) * client->format.redMax + 127) / 255 \
  25. << client->format.redShift | \
  26. @@ -54,6 +56,9 @@ rfbBool HandleCursorShape(rfbClient* client,int xhot, int yhot, int width, int h
  27. if (width * height == 0)
  28. return TRUE;
  29. + if (width >= MAX_CURSOR_SIZE || height >= MAX_CURSOR_SIZE)
  30. + return FALSE;
  31. +
  32. /* Allocate memory for pixel data and temporary mask data. */
  33. if(client->rcSource)
  34. free(client->rcSource);