Blame SOURCES/tigervnc-pixelformat-sanity-checks.patch

aeab07
diff --git a/common/rfb/PixelFormat.cxx b/common/rfb/PixelFormat.cxx
aeab07
index 76051dc..a9d015d 100644
aeab07
--- a/common/rfb/PixelFormat.cxx
aeab07
+++ b/common/rfb/PixelFormat.cxx
aeab07
@@ -75,7 +75,8 @@ PixelFormat::PixelFormat(int b, int d, bool e, bool t,
aeab07
     redMax(rm), greenMax(gm), blueMax(bm),
aeab07
     redShift(rs), greenShift(gs), blueShift(bs)
aeab07
 {
aeab07
-  assert(isSane());
aeab07
+  if (!isSane())
aeab07
+    throw Exception("invalid pixel format");
aeab07
 
aeab07
   updateState();
aeab07
 }
aeab07
@@ -672,8 +673,16 @@ bool PixelFormat::isSane(void)
aeab07
     return false;
aeab07
 
aeab07
   totalBits = bits(redMax) + bits(greenMax) + bits(blueMax);
aeab07
-  if (totalBits > bpp)
aeab07
+  if (totalBits > depth)
aeab07
+    return false;
aeab07
+
aeab07
+  if ((bits(redMax) + redShift) > bpp)
aeab07
+    return false;
aeab07
+  if ((bits(greenMax) + greenShift) > bpp)
aeab07
     return false;
aeab07
+  if ((bits(blueMax) + blueShift) > bpp)
aeab07
+    return false;
aeab07
+
aeab07
 
aeab07
   if (((redMax << redShift) & (greenMax << greenShift)) != 0)
aeab07
     return false;