aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2017-02-19 15:53:07 +0100
committerPierre Ossman <ossman@cendio.se>2017-02-22 16:59:20 +0100
commit1bbe02ba8b6882aaec0a7506c4df41762dfc1663 (patch)
treef9afc5d7da6bbe2af5f418332e6bc8ec296c7796 /common
parent6b68f977880530e95dc31a1f342a11f2c36b75a1 (diff)
downloadtigervnc-1bbe02ba8b6882aaec0a7506c4df41762dfc1663.tar.gz
tigervnc-1bbe02ba8b6882aaec0a7506c4df41762dfc1663.zip
Properly handle depth > 24 in ZRLE decoder
Diffstat (limited to 'common')
-rw-r--r--common/rfb/ZRLEDecoder.cxx36
1 files changed, 20 insertions, 16 deletions
diff --git a/common/rfb/ZRLEDecoder.cxx b/common/rfb/ZRLEDecoder.cxx
index b891ba52..1dfb72af 100644
--- a/common/rfb/ZRLEDecoder.cxx
+++ b/common/rfb/ZRLEDecoder.cxx
@@ -1,4 +1,5 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright 2009-2017 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -91,24 +92,27 @@ void ZRLEDecoder::decodeRect(const Rect& r, const void* buffer,
case 16: zrleDecode16(r, &is, &zis, pf, pb); break;
case 32:
{
- Pixel maxPixel = pf.pixelFromRGB((rdr::U16)-1, (rdr::U16)-1, (rdr::U16)-1);
- bool fitsInLS3Bytes = maxPixel < (1<<24);
- bool fitsInMS3Bytes = (maxPixel & 0xff) == 0;
+ if (pf.depth <= 24) {
+ Pixel maxPixel = pf.pixelFromRGB((rdr::U16)-1, (rdr::U16)-1, (rdr::U16)-1);
+ bool fitsInLS3Bytes = maxPixel < (1<<24);
+ bool fitsInMS3Bytes = (maxPixel & 0xff) == 0;
- if ((fitsInLS3Bytes && pf.isLittleEndian()) ||
- (fitsInMS3Bytes && pf.isBigEndian()))
- {
- zrleDecode24A(r, &is, &zis, pf, pb);
- }
- else if ((fitsInLS3Bytes && pf.isBigEndian()) ||
- (fitsInMS3Bytes && pf.isLittleEndian()))
- {
- zrleDecode24B(r, &is, &zis, pf, pb);
- }
- else
- {
- zrleDecode32(r, &is, &zis, pf, pb);
+ if ((fitsInLS3Bytes && pf.isLittleEndian()) ||
+ (fitsInMS3Bytes && pf.isBigEndian()))
+ {
+ zrleDecode24A(r, &is, &zis, pf, pb);
+ break;
+ }
+
+ if ((fitsInLS3Bytes && pf.isBigEndian()) ||
+ (fitsInMS3Bytes && pf.isLittleEndian()))
+ {
+ zrleDecode24B(r, &is, &zis, pf, pb);
+ break;
+ }
}
+
+ zrleDecode32(r, &is, &zis, pf, pb);
break;
}
}