aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2019-09-10 16:01:44 +0200
committerPierre Ossman <ossman@cendio.se>2019-12-20 07:29:00 +0100
commit6d71fe854b7b518c59f59c18d94edfd839043650 (patch)
treedc3b2adf5b3cded7cf7291baf5a6274929bcd4ae
parentde6109a66b086fcdf658562e3bcbba59747ebaef (diff)
downloadtigervnc-6d71fe854b7b518c59f59c18d94edfd839043650.tar.gz
tigervnc-6d71fe854b7b518c59f59c18d94edfd839043650.zip
Fix depth sanity test in PixelFormat
(cherry picked from commit f1b9b868ec943d51ef631f53a095d48d3f178f4f)
-rw-r--r--common/rfb/PixelFormat.cxx2
-rw-r--r--tests/unit/pixelformat.cxx4
2 files changed, 5 insertions, 1 deletions
diff --git a/common/rfb/PixelFormat.cxx b/common/rfb/PixelFormat.cxx
index 0be4d1da..2d8142d1 100644
--- a/common/rfb/PixelFormat.cxx
+++ b/common/rfb/PixelFormat.cxx
@@ -679,7 +679,7 @@ bool PixelFormat::isSane(void)
return false;
totalBits = bits(redMax) + bits(greenMax) + bits(blueMax);
- if (totalBits > bpp)
+ if (totalBits > depth)
return false;
if (((redMax << redShift) & (greenMax << greenShift)) != 0)
diff --git a/tests/unit/pixelformat.cxx b/tests/unit/pixelformat.cxx
index 4eb45281..7b6087f7 100644
--- a/tests/unit/pixelformat.cxx
+++ b/tests/unit/pixelformat.cxx
@@ -104,6 +104,10 @@ int main(int argc, char** argv)
doTest(true, 32, 24, false, true, 127, 511, 127, 0, 4, 20);
doTest(true, 32, 24, false, true, 127, 127, 511, 0, 4, 8);
+ /* Insufficient depth */
+
+ doTest(true, 32, 16, false, true, 255, 255, 255, 0, 8, 16);
+
/* Overlapping channels */
doTest(true, 32, 24, false, true, 255, 255, 255, 0, 7, 16);