瀏覽代碼

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.

(cherry picked from commit 05e2849087)
tags/v1.10.1
Pierre Ossman 4 年之前
父節點
當前提交
6c47340e09
共有 2 個文件被更改,包括 12 次插入0 次删除
  1. 6
    0
      common/rfb/PixelFormat.cxx
  2. 6
    0
      tests/unit/pixelformat.cxx

+ 6
- 0
common/rfb/PixelFormat.cxx 查看文件

@@ -206,6 +206,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;
}

+ 6
- 0
tests/unit/pixelformat.cxx 查看文件

@@ -170,6 +170,12 @@ void is888Tests()

do888Test(false, 8, 8, false, false, 0, 0, 0, 0, 0, 0);

/* Odd shifts */

do888Test(false, 32, 24, false, true, 255, 255, 255, 0, 8, 18);
do888Test(false, 32, 24, false, true, 255, 255, 255, 0, 11, 24);
do888Test(false, 32, 24, false, true, 255, 255, 255, 4, 16, 24);

printf("\n");
}


Loading…
取消
儲存