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.
pull/38/head
Jay Carlson 9 years ago committed by Slávek Banko
parent f73675cdcb
commit c84d8d813c
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -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)

Loading…
Cancel
Save