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

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