summaryrefslogtreecommitdiffstats
path: root/krdc/vnc/rfbproto.c
diff options
context:
space:
mode:
authorJay Carlson <nop@nop.com>2015-03-27 11:22:13 -0400
committerSlávek Banko <slavek.banko@axis.cz>2019-02-06 23:34:37 +0100
commitc84d8d813c97c6d9f518bd77a4cf2a99b01a12a0 (patch)
tree68fdcebe2714d9bde313bd32d7d9b110cc158d7c /krdc/vnc/rfbproto.c
parentf73675cdcbe106151014f62b92c989d92e09c3f7 (diff)
downloadtdenetwork-c84d8d813c97c6d9f518bd77a4cf2a99b01a12a0.tar.gz
tdenetwork-c84d8d813c97c6d9f518bd77a4cf2a99b01a12a0.zip
Avoid divide-by-zero in raw encoding (OSX RealVNC)
OS X RealVNC server crashes out Remmina because the server can provoke bytesPerLine to be zero. Assume this is coding for zero lines. The condition could be checked before the calculation of bytesPerLine. I don’t understand the preconditions of this code to say one way or the other.
Diffstat (limited to 'krdc/vnc/rfbproto.c')
-rw-r--r--krdc/vnc/rfbproto.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/krdc/vnc/rfbproto.c b/krdc/vnc/rfbproto.c
index 587e9d1c..82aa9af2 100644
--- a/krdc/vnc/rfbproto.c
+++ b/krdc/vnc/rfbproto.c
@@ -982,7 +982,10 @@ HandleRFBServerMessage()
case rfbEncodingRaw:
bytesPerLine = rect.r.w * myFormat.bitsPerPixel / 8;
- linesToRead = BUFFER_SIZE / bytesPerLine;
+ /* RealVNC 4.x-5.x on OSX can induce bytesPerLine==0,
+ usually during GPU accel. */
+ /* Regardless of cause, do not divide by zero. */
+ linesToRead = bytesPerLine ? (BUFFER_SIZE / bytesPerLine) : 0;
while (rect.r.h > 0) {
if (linesToRead > rect.r.h)