Description: CVE-2019-8287
 (same as CVE-2018-20020/libvncserver)
 heap out-of-bound write vulnerability inside structure in VNC client code that
 can result remote code execution
Origin: https://github.com/LibVNC/libvncserver/commit/7b1ef0ffc4815cab9a96c7278394152bdc89dc4d
Bug: https://github.com/LibVNC/libvncserver/issues/250
Bug-Debian: https://bugs.debian.org/916941

[sunweaver] port libvncclient patch over to tightvnc's vncviewer code

--- a/vncviewer/corre.c
+++ b/vncviewer/corre.c
@@ -56,7 +56,7 @@
     XChangeGC(dpy, gc, GCForeground, &gcv);
     XFillRectangle(dpy, desktopWin, gc, rx, ry, rw, rh);
 
-    if (!ReadFromRFBServer(buffer, hdr.nSubrects * (4 + (BPP / 8))))
+    if (hdr.nSubrects > BUFFER_SIZE / (4 + (BPP / 8)) || !ReadFromRFBServer(buffer, hdr.nSubrects * (4 + (BPP / 8))))
 	return False;
 
     ptr = (CARD8 *)buffer;
