summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-09-16 14:17:35 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-09-17 08:51:27 +0000
commitd96b939fbfb140d605965f379b526786e7cc613e (patch)
tree4f59c852dc449c0bd0a9b218e671bc117e0721ae /vcl/unx
parent57ad819ca658cb94c84ee30846d6781a5f931973 (diff)
make CalcMaskShift a verifiable operation
and check it on untrusted data Change-Id: I7c97a27d70f91b9686adf9dcb8b68c5aa25c2b4c Reviewed-on: https://gerrit.libreoffice.org/18637 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx36
1 files changed, 32 insertions, 4 deletions
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index c6c156b2c29b..82044492904f 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -154,14 +154,30 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
case( 8 ): pDIB->mnFormat |= BMP_FORMAT_8BIT_PAL; break;
#ifdef OSL_BIGENDIAN
case(16 ):
+ {
pDIB->mnFormat|= BMP_FORMAT_16BIT_TC_MSB_MASK;
- pDIB->maColorMask = ColorMask( 0xf800, 0x07e0, 0x001f );
+ ColorMaskElement aRedMask(0xf800);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(0x07e0);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(0x001f);
+ aBlueMask.CalcMaskShift();
+ pDIB->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
break;
+ }
#else
case(16 ):
+ {
pDIB->mnFormat|= BMP_FORMAT_16BIT_TC_LSB_MASK;
- pDIB->maColorMask = ColorMask( 0xf800, 0x07e0, 0x001f );
+ ColorMaskElement aRedMask(0xf800);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(0x07e0);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(0x001f);
+ aBlueMask.CalcMaskShift();
+ pDIB->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
break;
+ }
#endif
default:
nBitCount = 24;
@@ -274,7 +290,13 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
case( 16 ):
{
- aSrcBuf.maColorMask = ColorMask( pImage->red_mask, pImage->green_mask, pImage->blue_mask );
+ ColorMaskElement aRedMask(pImage->red_mask);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(pImage->green_mask);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(pImage->blue_mask);
+ aBlueMask.CalcMaskShift();
+ aSrcBuf.maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
if( LSBFirst == pImage->byte_order )
{
@@ -444,7 +466,13 @@ XImage* X11SalBitmap::ImplCreateXImage(
#endif
- xMask.reset(new ColorMask( pImage->red_mask, pImage->green_mask, pImage->blue_mask ));
+ ColorMaskElement aRedMask(pImage->red_mask);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(pImage->green_mask);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(pImage->blue_mask);
+ aBlueMask.CalcMaskShift();
+ xMask.reset(new ColorMask(aRedMask, aGreenMask, aBlueMask));
}
break;