Added length arguments and checks.
This commit is contained in:
parent
416ac0baea
commit
4a62e6bee4
@ -237,9 +237,12 @@ BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (freerdp_image_copy_from_pointer_data((BYTE*) ci.pixels, PIXEL_FORMAT_ARGB32,
|
||||
pointer->width * 4, 0, 0, pointer->width, pointer->height,
|
||||
pointer->xorMaskData, pointer->andMaskData, pointer->xorBpp, xfc->palette) < 0)
|
||||
if (freerdp_image_copy_from_pointer_data(
|
||||
(BYTE*) ci.pixels, PIXEL_FORMAT_ARGB32,
|
||||
pointer->width * 4, 0, 0, pointer->width, pointer->height,
|
||||
pointer->xorMaskData, pointer->lengthXorMask,
|
||||
pointer->andMaskData, pointer->lengthAndMask,
|
||||
pointer->xorBpp, xfc->palette) < 0)
|
||||
{
|
||||
free(ci.pixels);
|
||||
xf_unlock_x11(xfc, FALSE);
|
||||
|
@ -376,12 +376,12 @@ extern "C" {
|
||||
|
||||
#define BGR16_RGB32(_r, _g, _b, _p) \
|
||||
GetBGR16(_r, _g, _b, _p); \
|
||||
RGB_565_888(_r, _g, _b); \
|
||||
RGB_565_888(_r, _g, _b); \
|
||||
_p = RGB32(_r, _g, _b);
|
||||
|
||||
#define RGB32_RGB16(_r, _g, _b, _p) \
|
||||
GetRGB32(_r, _g, _b, _p); \
|
||||
RGB_888_565(_r, _g, _b); \
|
||||
RGB_888_565(_r, _g, _b); \
|
||||
_p = RGB565(_r, _g, _b);
|
||||
|
||||
#define RGB15_RGB16(_r, _g, _b, _p) \
|
||||
@ -452,8 +452,11 @@ FREERDP_API void freerdp_clrconv_free(HCLRCONV clrconv);
|
||||
FREERDP_API int freerdp_image_copy_from_monochrome(BYTE* pDstData, UINT32 DstFormat, int nDstStep, int nXDst, int nYDst,
|
||||
int nWidth, int nHeight, BYTE* pSrcData, UINT32 backColor, UINT32 foreColor, BYTE* palette);
|
||||
|
||||
FREERDP_API int freerdp_image_copy_from_pointer_data(BYTE* pDstData, UINT32 DstFormat, int nDstStep, int nXDst, int nYDst,
|
||||
int nWidth, int nHeight, BYTE* xorMask, BYTE* andMask, UINT32 xorBpp, BYTE* palette);
|
||||
FREERDP_API int int freerdp_image_copy_from_pointer_data(
|
||||
BYTE* pDstData, UINT32 DstFormat, int nDstStep,
|
||||
int nXDst, int nYDst, int nWidth, int nHeight, BYTE* xorMask,
|
||||
UINT32 xorMaskLength, BYTE* andMask, UINT32 andMaskLength,
|
||||
UINT32 xorBpp, BYTE* palette);
|
||||
|
||||
FREERDP_API int freerdp_image8_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst,
|
||||
int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette);
|
||||
|
@ -1426,8 +1426,12 @@ void freerdp_alpha_cursor_convert(BYTE* alphaData, BYTE* xorMask, BYTE* andMask,
|
||||
* http://msdn.microsoft.com/en-us/library/windows/hardware/ff556138/
|
||||
*/
|
||||
|
||||
int freerdp_image_copy_from_pointer_data(BYTE* pDstData, UINT32 DstFormat, int nDstStep, int nXDst, int nYDst,
|
||||
int nWidth, int nHeight, BYTE* xorMask, BYTE* andMask, UINT32 xorBpp, BYTE* palette)
|
||||
int freerdp_image_copy_from_pointer_data(BYTE* pDstData, UINT32 DstFormat,
|
||||
int nDstStep, int nXDst, int nYDst,
|
||||
int nWidth, int nHeight, BYTE* xorMask,
|
||||
UINT32 xorMaskLength, BYTE* andMask,
|
||||
UINT32 andMaskLength, UINT32 xorBpp,
|
||||
BYTE* palette)
|
||||
{
|
||||
int x, y;
|
||||
BOOL vFlip;
|
||||
@ -1463,7 +1467,7 @@ int freerdp_image_copy_from_pointer_data(BYTE* pDstData, UINT32 DstFormat, int n
|
||||
andStep = (nWidth + 7) / 8;
|
||||
andStep += (andStep % 2);
|
||||
|
||||
if (!xorMask)
|
||||
if (!xorMask || (xorMaskLength == 0))
|
||||
return -1;
|
||||
|
||||
if (dstBytesPerPixel == 4)
|
||||
@ -1472,12 +1476,18 @@ int freerdp_image_copy_from_pointer_data(BYTE* pDstData, UINT32 DstFormat, int n
|
||||
|
||||
if (xorBpp == 1)
|
||||
{
|
||||
if (!andMask)
|
||||
if (!andMask || (andMaskLength == 0))
|
||||
return -1;
|
||||
|
||||
xorStep = (nWidth + 7) / 8;
|
||||
xorStep += (xorStep % 2);
|
||||
|
||||
if (xorStep * nHeight > xorMaskLength)
|
||||
return -1;
|
||||
|
||||
if (andStep * nHeight > andMaskLength)
|
||||
return -1;
|
||||
|
||||
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
||||
|
||||
for (y = 0; y < nHeight; y++)
|
||||
@ -1531,6 +1541,15 @@ int freerdp_image_copy_from_pointer_data(BYTE* pDstData, UINT32 DstFormat, int n
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xorStep * nHeight > xorMaskLength)
|
||||
return -1;
|
||||
|
||||
if (andMask)
|
||||
{
|
||||
if (andStep * nHeight > andMaskLength)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (y = 0; y < nHeight; y++)
|
||||
{
|
||||
andBit = 0x80;
|
||||
|
Loading…
Reference in New Issue
Block a user