From: Christian Beier <dontmind@freeshell.org>
Date: Sat, 29 Sep 2018 21:32:59 +0200
Subject: LibVNCClient: fix possible infinite loop
Origin: https://github.com/LibVNC/libvncserver/commit/c3115350eb8bb635d0fdb4dbbb0d0541f38ed19c
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2018-20021
Bug-Debian: https://bugs.debian.org/916941
Bug: https://github.com/LibVNC/libvncserver/issues/251

Closes #251
---
 libvncclient/rfbproto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/libvncclient/rfbproto.c
+++ b/libvncclient/rfbproto.c
@@ -1973,7 +1973,7 @@
 	/* Regardless of cause, do not divide by zero. */
 	linesToRead = bytesPerLine ? (RFB_BUFFER_SIZE / bytesPerLine) : 0;
 
-	while (h > 0) {
+	while (linesToRead && h > 0) {
 	  if (linesToRead > h)
 	    linesToRead = h;
 
