summaryrefslogtreecommitdiffstats
path: root/libvncserver
diff options
context:
space:
mode:
authorChristian Beier <dontmind@freeshell.org>2018-03-24 01:56:21 +0100
committerChristian Beier <dontmind@freeshell.org>2018-03-24 01:56:21 +0100
commitb0c77391e6bd0a2305bbc9b37a2499af74ddd9ee (patch)
treef99cc2b57d55c8ce2c4e3349c5c16d0321e9255c /libvncserver
parent078590786cfc477785729620e4bc5585e13b22f7 (diff)
parent28afb6c537dc82ba04d5f245b15ca7205c6dbb9c (diff)
downloadlibtdevnc-b0c77391e6bd0a2305bbc9b37a2499af74ddd9ee.tar.gz
libtdevnc-b0c77391e6bd0a2305bbc9b37a2499af74ddd9ee.zip
Merge branch 'clientcuttext' of https://github.com/ppisar/libvncserver into ppisar-clientcuttext
Diffstat (limited to 'libvncserver')
-rw-r--r--libvncserver/rfbserver.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c
index 116c488..4fc4d9d 100644
--- a/libvncserver/rfbserver.c
+++ b/libvncserver/rfbserver.c
@@ -88,6 +88,8 @@
#include <errno.h>
/* strftime() */
#include <time.h>
+/* PRIu32 */
+#include <inttypes.h>
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
#include "rfbssl.h"
@@ -2575,7 +2577,23 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
msg.cct.length = Swap32IfLE(msg.cct.length);
- str = (char *)malloc(msg.cct.length);
+ /* uint32_t input is passed to malloc()'s size_t argument,
+ * to rfbReadExact()'s int argument, to rfbStatRecordMessageRcvd()'s int
+ * argument increased of sz_rfbClientCutTextMsg, and to setXCutText()'s int
+ * argument. Here we impose a limit of 1 MB so that the value fits
+ * into all of the types to prevent from misinterpretation and thus
+ * from accessing uninitialized memory (CVE-2018-7225) and also to
+ * prevent from a denial-of-service by allocating to much memory in
+ * the server. */
+ if (msg.cct.length > 1<<20) {
+ rfbLog("rfbClientCutText: too big cut text length requested: %" PRIu32 "\n",
+ msg.cct.length);
+ rfbCloseClient(cl);
+ return;
+ }
+
+ /* Allow zero-length client cut text. */
+ str = (char *)calloc(msg.cct.length ? msg.cct.length : 1, 1);
if (str == NULL) {
rfbLogPerror("rfbProcessClientNormalMessage: not enough memory");
rfbCloseClient(cl);