From ed73ac2aa776875f218cb0fd09f68be79a8f5191 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 2 Oct 2019 16:06:08 +0200 Subject: [PATCH] Handle pixel formats with odd shift values Our fast paths assume that each channel fits in to a separate byte. That means the shift needs to be a multiple of 8. Start actually checking this so that a client cannot trip us up and possibly cause incorrect code exection. Issue found by Pavel Cheremushkin from Kaspersky Lab. --- common/rfb/PixelFormat.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/rfb/PixelFormat.cxx b/common/rfb/PixelFormat.cxx index 52e267a..185d437 100644 --- a/common/rfb/PixelFormat.cxx +++ b/common/rfb/PixelFormat.cxx @@ -205,6 +205,12 @@ bool PixelFormat::is888(void) const return false; if (blueMax != 255) return false; + if ((redShift & 0x7) != 0) + return false; + if ((greenShift & 0x7) != 0) + return false; + if ((blueShift & 0x7) != 0) + return false; return true; }