Merge pull request #4926 from akallabeth/primary_order_checks

Order data validation and correction
This commit is contained in:
Martin Fleisz 2018-10-17 16:02:28 +02:00 committed by GitHub
commit e46d1d95ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 1369 additions and 594 deletions

View File

@ -1197,7 +1197,7 @@ static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd)
{ {
if (rdpsnd) if (rdpsnd)
{ {
audio_format_free(rdpsnd->fixed_format); audio_formats_free(rdpsnd->fixed_format, 1);
free(rdpsnd->subsystem); free(rdpsnd->subsystem);
free(rdpsnd->device_name); free(rdpsnd->device_name);
CloseHandle(rdpsnd->stopEvent); CloseHandle(rdpsnd->stopEvent);

View File

@ -1108,9 +1108,9 @@ static BOOL xf_pre_connect(freerdp* instance)
settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = settings->BitmapCacheEnabled; settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = settings->BitmapCacheEnabled;
settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = settings->BitmapCacheEnabled; settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = settings->BitmapCacheEnabled;
settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE; settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE;
settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE; settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = settings->GlyphSupportLevel != GLYPH_SUPPORT_NONE;
settings->OrderSupport[NEG_FAST_INDEX_INDEX] = TRUE; settings->OrderSupport[NEG_FAST_INDEX_INDEX] = settings->GlyphSupportLevel != GLYPH_SUPPORT_NONE;
settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = TRUE; settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = settings->GlyphSupportLevel != GLYPH_SUPPORT_NONE;
settings->OrderSupport[NEG_POLYGON_SC_INDEX] = FALSE; settings->OrderSupport[NEG_POLYGON_SC_INDEX] = FALSE;
settings->OrderSupport[NEG_POLYGON_CB_INDEX] = FALSE; settings->OrderSupport[NEG_POLYGON_CB_INDEX] = FALSE;
settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE; settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE;

View File

@ -1756,6 +1756,10 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
{ {
settings->ConsoleSession = enable; settings->ConsoleSession = enable;
} }
CommandLineSwitchCase(arg, "relax-order-checks")
{
settings->AllowUnanouncedOrdersFromServer = arg->Value;
}
CommandLineSwitchCase(arg, "restricted-admin") CommandLineSwitchCase(arg, "restricted-admin")
{ {
settings->ConsoleSession = enable; settings->ConsoleSession = enable;

View File

@ -142,6 +142,7 @@ static COMMAND_LINE_ARGUMENT_A args[] =
{ "pwidth", COMMAND_LINE_VALUE_REQUIRED, "<width>", NULL, NULL, -1, NULL, "Physical width of display (in millimeters)" }, { "pwidth", COMMAND_LINE_VALUE_REQUIRED, "<width>", NULL, NULL, -1, NULL, "Physical width of display (in millimeters)" },
{ "reconnect-cookie", COMMAND_LINE_VALUE_REQUIRED, "<base64-cookie>", NULL, NULL, -1, NULL, "Pass base64 reconnect cookie to the connection" }, { "reconnect-cookie", COMMAND_LINE_VALUE_REQUIRED, "<base64-cookie>", NULL, NULL, -1, NULL, "Pass base64 reconnect cookie to the connection" },
{ "redirect-prefer", COMMAND_LINE_VALUE_REQUIRED, "<FQDN|IP|NETBIOS>[,<FQDN|IP|NETBIOS>[,<FQDN|IP|NETBIOS>]]", NULL, NULL, -1, NULL, "Override the preferred redirection order" }, { "redirect-prefer", COMMAND_LINE_VALUE_REQUIRED, "<FQDN|IP|NETBIOS>[,<FQDN|IP|NETBIOS>[,<FQDN|IP|NETBIOS>]]", NULL, NULL, -1, NULL, "Override the preferred redirection order" },
{ "relax-order-checks", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "relax-order-checks", "Do not check if a RDP order was announced during capability exchange, only use when connecting to a buggy server" },
{ "restricted-admin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "restrictedAdmin", "Restricted admin mode" }, { "restricted-admin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "restrictedAdmin", "Restricted admin mode" },
{ "rfx", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "RemoteFX" }, { "rfx", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "RemoteFX" },
{ "rfx-mode", COMMAND_LINE_VALUE_REQUIRED, "image|video", NULL, NULL, -1, NULL, "RemoteFX mode" }, { "rfx-mode", COMMAND_LINE_VALUE_REQUIRED, "image|video", NULL, NULL, -1, NULL, "RemoteFX mode" },

View File

@ -212,7 +212,7 @@ struct _MULTI_DRAW_NINE_GRID_ORDER
UINT32 bitmapId; UINT32 bitmapId;
UINT32 nDeltaEntries; UINT32 nDeltaEntries;
UINT32 cbData; UINT32 cbData;
BYTE* codeDeltaList; DELTA_RECT rectangles[45];
}; };
typedef struct _MULTI_DRAW_NINE_GRID_ORDER MULTI_DRAW_NINE_GRID_ORDER; typedef struct _MULTI_DRAW_NINE_GRID_ORDER MULTI_DRAW_NINE_GRID_ORDER;

View File

@ -165,15 +165,15 @@
#define NEG_MEMBLT_INDEX 0x03 #define NEG_MEMBLT_INDEX 0x03
#define NEG_MEM3BLT_INDEX 0x04 #define NEG_MEM3BLT_INDEX 0x04
#define NEG_ATEXTOUT_INDEX 0x05 #define NEG_ATEXTOUT_INDEX 0x05
#define NEG_AEXTTEXTOUT_INDEX 0x06 #define NEG_AEXTTEXTOUT_INDEX 0x06 /* Must be ignored */
#define NEG_DRAWNINEGRID_INDEX 0x07 #define NEG_DRAWNINEGRID_INDEX 0x07 /* Must be ignored */
#define NEG_LINETO_INDEX 0x08 #define NEG_LINETO_INDEX 0x08
#define NEG_MULTI_DRAWNINEGRID_INDEX 0x09 #define NEG_MULTI_DRAWNINEGRID_INDEX 0x09
#define NEG_OPAQUE_RECT_INDEX 0x0A #define NEG_OPAQUE_RECT_INDEX 0x0A /* Must be ignored */
#define NEG_SAVEBITMAP_INDEX 0x0B #define NEG_SAVEBITMAP_INDEX 0x0B
#define NEG_WTEXTOUT_INDEX 0x0C #define NEG_WTEXTOUT_INDEX 0x0C /* Must be ignored */
#define NEG_MEMBLT_V2_INDEX 0x0D #define NEG_MEMBLT_V2_INDEX 0x0D /* Must be ignored */
#define NEG_MEM3BLT_V2_INDEX 0x0E #define NEG_MEM3BLT_V2_INDEX 0x0E /* Must be ignored */
#define NEG_MULTIDSTBLT_INDEX 0x0F #define NEG_MULTIDSTBLT_INDEX 0x0F
#define NEG_MULTIPATBLT_INDEX 0x10 #define NEG_MULTIPATBLT_INDEX 0x10
#define NEG_MULTISCRBLT_INDEX 0x11 #define NEG_MULTISCRBLT_INDEX 0x11
@ -182,15 +182,15 @@
#define NEG_POLYGON_SC_INDEX 0x14 #define NEG_POLYGON_SC_INDEX 0x14
#define NEG_POLYGON_CB_INDEX 0x15 #define NEG_POLYGON_CB_INDEX 0x15
#define NEG_POLYLINE_INDEX 0x16 #define NEG_POLYLINE_INDEX 0x16
#define NEG_UNUSED23_INDEX 0x17 #define NEG_UNUSED23_INDEX 0x17 /* Must be ignored */
#define NEG_FAST_GLYPH_INDEX 0x18 #define NEG_FAST_GLYPH_INDEX 0x18
#define NEG_ELLIPSE_SC_INDEX 0x19 #define NEG_ELLIPSE_SC_INDEX 0x19
#define NEG_ELLIPSE_CB_INDEX 0x1A #define NEG_ELLIPSE_CB_INDEX 0x1A
#define NEG_GLYPH_INDEX_INDEX 0x1B #define NEG_GLYPH_INDEX_INDEX 0x1B
#define NEG_GLYPH_WEXTTEXTOUT_INDEX 0x1C #define NEG_GLYPH_WEXTTEXTOUT_INDEX 0x1C /* Must be ignored */
#define NEG_GLYPH_WLONGTEXTOUT_INDEX 0x1D #define NEG_GLYPH_WLONGTEXTOUT_INDEX 0x1D /* Must be ignored */
#define NEG_GLYPH_WLONGEXTTEXTOUT_INDEX 0x1E #define NEG_GLYPH_WLONGEXTTEXTOUT_INDEX 0x1E /* Must be ignored */
#define NEG_UNUSED31_INDEX 0x1F #define NEG_UNUSED31_INDEX 0x1F /* Must be ignored */
/* Glyph Support Level */ /* Glyph Support Level */
#define GLYPH_SUPPORT_NONE 0x0000 #define GLYPH_SUPPORT_NONE 0x0000
@ -1265,7 +1265,8 @@ struct rdp_settings
ALIGN64 BYTE* OrderSupport; /* 2432 */ ALIGN64 BYTE* OrderSupport; /* 2432 */
ALIGN64 BOOL BitmapCacheV3Enabled; /* 2433 */ ALIGN64 BOOL BitmapCacheV3Enabled; /* 2433 */
ALIGN64 BOOL AltSecFrameMarkerSupport; /* 2434 */ ALIGN64 BOOL AltSecFrameMarkerSupport; /* 2434 */
UINT64 padding2497[2497 - 2435]; /* 2435 */ ALIGN64 BOOL AllowUnanouncedOrdersFromServer; /* 2435 */
UINT64 padding2497[2497 - 2436]; /* 2436 */
/* Bitmap Cache Capabilities */ /* Bitmap Cache Capabilities */
ALIGN64 BOOL BitmapCacheEnabled; /* 2497 */ ALIGN64 BOOL BitmapCacheEnabled; /* 2497 */

View File

@ -87,6 +87,9 @@ BOOL freerdp_image_copy_from_monochrome(BYTE* pDstData, UINT32 DstFormat,
UINT32 monoStep; UINT32 monoStep;
const UINT32 dstBytesPerPixel = GetBytesPerPixel(DstFormat); const UINT32 dstBytesPerPixel = GetBytesPerPixel(DstFormat);
if (!pDstData || !pSrcData || !palette)
return FALSE;
if (nDstStep == 0) if (nDstStep == 0)
nDstStep = dstBytesPerPixel * nWidth; nDstStep = dstBytesPerPixel * nWidth;
@ -203,7 +206,7 @@ BOOL freerdp_image_copy_from_pointer_data(
const BYTE* andBits; const BYTE* andBits;
const BYTE* xorBits; const BYTE* xorBits;
BYTE* pDstPixel = &pDstData[((nYDst + y) * nDstStep) + BYTE* pDstPixel = &pDstData[((nYDst + y) * nDstStep) +
(nXDst * GetBytesPerPixel(DstFormat))]; (nXDst * GetBytesPerPixel(DstFormat))];
xorBit = andBit = 0x80; xorBit = andBit = 0x80;
if (!vFlip) if (!vFlip)
@ -281,7 +284,7 @@ BOOL freerdp_image_copy_from_pointer_data(
const BYTE* xorBits; const BYTE* xorBits;
const BYTE* andBits = NULL; const BYTE* andBits = NULL;
BYTE* pDstPixel = &pDstData[((nYDst + y) * nDstStep) + BYTE* pDstPixel = &pDstData[((nYDst + y) * nDstStep) +
(nXDst * GetBytesPerPixel(DstFormat))]; (nXDst * GetBytesPerPixel(DstFormat))];
andBit = 0x80; andBit = 0x80;
if (!vFlip) if (!vFlip)
@ -326,9 +329,9 @@ BOOL freerdp_image_copy_from_pointer_data(
} }
xorPixel = FreeRDPConvertColor(xorPixel, xorPixel = FreeRDPConvertColor(xorPixel,
pixelFormat, pixelFormat,
PIXEL_FORMAT_ARGB32, PIXEL_FORMAT_ARGB32,
palette); palette);
xorBits += xorBytesPerPixel; xorBits += xorBytesPerPixel;
andPixel = 0; andPixel = 0;
@ -352,7 +355,7 @@ BOOL freerdp_image_copy_from_pointer_data(
} }
color = FreeRDPConvertColor(xorPixel, PIXEL_FORMAT_ARGB32, color = FreeRDPConvertColor(xorPixel, PIXEL_FORMAT_ARGB32,
DstFormat, palette); DstFormat, palette);
WriteColor(pDstPixel, DstFormat, color); WriteColor(pDstPixel, DstFormat, color);
pDstPixel += GetBytesPerPixel(DstFormat); pDstPixel += GetBytesPerPixel(DstFormat);
} }
@ -435,11 +438,11 @@ BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat,
for (y = 0; y < nHeight; y++) for (y = 0; y < nHeight; y++)
{ {
const BYTE* srcLine = &pSrcData[(y + nYSrc) * const BYTE* srcLine = &pSrcData[(y + nYSrc) *
nSrcStep * srcVMultiplier + nSrcStep * srcVMultiplier +
srcVOffset]; srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) * BYTE* dstLine = &pDstData[(y + nYDst) *
nDstStep * dstVMultiplier + nDstStep * dstVMultiplier +
dstVOffset]; dstVOffset];
memcpy(&dstLine[xDstOffset], memcpy(&dstLine[xDstOffset],
&srcLine[xSrcOffset], copyDstWidth); &srcLine[xSrcOffset], copyDstWidth);
} }
@ -450,11 +453,11 @@ BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat,
for (y = nHeight - 1; y >= 0; y--) for (y = nHeight - 1; y >= 0; y--)
{ {
const BYTE* srcLine = &pSrcData[(y + nYSrc) * const BYTE* srcLine = &pSrcData[(y + nYSrc) *
nSrcStep * srcVMultiplier + nSrcStep * srcVMultiplier +
srcVOffset]; srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) * BYTE* dstLine = &pDstData[(y + nYDst) *
nDstStep * dstVMultiplier + nDstStep * dstVMultiplier +
dstVOffset]; dstVOffset];
memcpy(&dstLine[xDstOffset], memcpy(&dstLine[xDstOffset],
&srcLine[xSrcOffset], copyDstWidth); &srcLine[xSrcOffset], copyDstWidth);
} }
@ -465,11 +468,11 @@ BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat,
for (y = 0; y < nHeight; y++) for (y = 0; y < nHeight; y++)
{ {
const BYTE* srcLine = &pSrcData[(y + nYSrc) * const BYTE* srcLine = &pSrcData[(y + nYSrc) *
nSrcStep * srcVMultiplier + nSrcStep * srcVMultiplier +
srcVOffset]; srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) * BYTE* dstLine = &pDstData[(y + nYDst) *
nDstStep * dstVMultiplier + nDstStep * dstVMultiplier +
dstVOffset]; dstVOffset];
memmove(&dstLine[xDstOffset], memmove(&dstLine[xDstOffset],
&srcLine[xSrcOffset], copyDstWidth); &srcLine[xSrcOffset], copyDstWidth);
} }
@ -480,11 +483,11 @@ BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat,
for (y = nHeight - 1; y >= 0; y--) for (y = nHeight - 1; y >= 0; y--)
{ {
const BYTE* srcLine = &pSrcData[(y + nYSrc) * const BYTE* srcLine = &pSrcData[(y + nYSrc) *
nSrcStep * srcVMultiplier + nSrcStep * srcVMultiplier +
srcVOffset]; srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) * BYTE* dstLine = &pDstData[(y + nYDst) *
nDstStep * dstVMultiplier + nDstStep * dstVMultiplier +
dstVOffset]; dstVOffset];
memmove(&dstLine[xDstOffset], memmove(&dstLine[xDstOffset],
&srcLine[xSrcOffset], copyDstWidth); &srcLine[xSrcOffset], copyDstWidth);
} }
@ -499,11 +502,11 @@ BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat,
for (y = 0; y < nHeight; y++) for (y = 0; y < nHeight; y++)
{ {
const BYTE* srcLine = &pSrcData[(y + nYSrc) * const BYTE* srcLine = &pSrcData[(y + nYSrc) *
nSrcStep * srcVMultiplier + nSrcStep * srcVMultiplier +
srcVOffset]; srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) * BYTE* dstLine = &pDstData[(y + nYDst) *
nDstStep * dstVMultiplier + nDstStep * dstVMultiplier +
dstVOffset]; dstVOffset];
memcpy(&dstLine[xDstOffset], memcpy(&dstLine[xDstOffset],
&srcLine[xSrcOffset], copyDstWidth); &srcLine[xSrcOffset], copyDstWidth);
} }
@ -516,10 +519,10 @@ BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat,
for (y = 0; y < nHeight; y++) for (y = 0; y < nHeight; y++)
{ {
const BYTE* srcLine = &pSrcData[(y + nYSrc) * const BYTE* srcLine = &pSrcData[(y + nYSrc) *
nSrcStep * srcVMultiplier + nSrcStep * srcVMultiplier +
srcVOffset]; srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) * BYTE* dstLine = &pDstData[(y + nYDst) *
nDstStep * dstVMultiplier + dstVOffset]; nDstStep * dstVMultiplier + dstVOffset];
for (x = 0; x < nWidth; x++) for (x = 0; x < nWidth; x++)
{ {

View File

@ -292,7 +292,7 @@ static INLINE BYTE* WRITEFIRSTLINEFGBGIMAGE(BYTE* pbDest, BYTE bitmask,
/** /**
* Decompress an RLE compressed bitmap. * Decompress an RLE compressed bitmap.
*/ */
static INLINE void RLEDECOMPRESS(const BYTE* pbSrcBuffer, UINT32 cbSrcBuffer, static INLINE BOOL RLEDECOMPRESS(const BYTE* pbSrcBuffer, UINT32 cbSrcBuffer,
BYTE* pbDestBuffer, BYTE* pbDestBuffer,
UINT32 rowDelta, UINT32 width, UINT32 height) UINT32 rowDelta, UINT32 width, UINT32 height)
{ {
@ -310,6 +310,9 @@ static INLINE void RLEDECOMPRESS(const BYTE* pbSrcBuffer, UINT32 cbSrcBuffer,
UINT32 advance; UINT32 advance;
RLEEXTRA RLEEXTRA
if (!pbSrcBuffer || !pbDestBuffer)
return FALSE;
while (pbSrc < pbEnd) while (pbSrc < pbEnd)
{ {
/* Watch out for the end of the first scanline. */ /* Watch out for the end of the first scanline. */
@ -628,6 +631,11 @@ static INLINE void RLEDECOMPRESS(const BYTE* pbSrcBuffer, UINT32 cbSrcBuffer,
DESTWRITEPIXEL(pbDest, BLACK_PIXEL); DESTWRITEPIXEL(pbDest, BLACK_PIXEL);
DESTNEXTPIXEL(pbDest); DESTNEXTPIXEL(pbDest);
break; break;
default:
return FALSE;
} }
} }
return TRUE;
} }

View File

@ -276,7 +276,7 @@ BOOL interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
UINT32 SrcFormat; UINT32 SrcFormat;
UINT32 BufferSize; UINT32 BufferSize;
if (!interleaved) if (!interleaved || !pSrcData || !pDstData)
return FALSE; return FALSE;
switch (bpp) switch (bpp)
@ -322,19 +322,25 @@ BOOL interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
switch (bpp) switch (bpp)
{ {
case 24: case 24:
RleDecompress24to24(pSrcData, SrcSize, interleaved->TempBuffer, if (!RleDecompress24to24(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nSrcWidth, nSrcHeight); scanline, nSrcWidth, nSrcHeight))
return FALSE;
break; break;
case 16: case 16:
case 15: case 15:
RleDecompress16to16(pSrcData, SrcSize, interleaved->TempBuffer, if (!RleDecompress16to16(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nSrcWidth, nSrcHeight); scanline, nSrcWidth, nSrcHeight))
return FALSE;
break; break;
case 8: case 8:
RleDecompress8to8(pSrcData, SrcSize, interleaved->TempBuffer, if (!RleDecompress8to8(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nSrcWidth, nSrcHeight); scanline, nSrcWidth, nSrcHeight))
return FALSE;
break; break;
default: default:

View File

@ -1453,7 +1453,7 @@ static BOOL rdp_write_brush_capability_set(wStream* s, rdpSettings* settings)
return FALSE; return FALSE;
header = rdp_capability_set_start(s); header = rdp_capability_set_start(s);
Stream_Write_UINT32(s, BRUSH_COLOR_FULL); /* brushSupportLevel (4 bytes) */ Stream_Write_UINT32(s, settings->BrushSupportLevel); /* brushSupportLevel (4 bytes) */
rdp_capability_set_finish(s, header, CAPSET_TYPE_BRUSH); rdp_capability_set_finish(s, header, CAPSET_TYPE_BRUSH);
return TRUE; return TRUE;
} }

View File

@ -265,15 +265,24 @@ static BOOL fastpath_recv_orders(rdpFastPath* fastpath, wStream* s)
UINT16 numberOrders; UINT16 numberOrders;
if (!fastpath || !fastpath->rdp || !s) if (!fastpath || !fastpath->rdp || !s)
{
WLog_ERR(TAG, "Invalid arguments");
return FALSE; return FALSE;
}
update = fastpath->rdp->update; update = fastpath->rdp->update;
if (!update) if (!update)
{
WLog_ERR(TAG, "Invalid configuration");
return FALSE; return FALSE;
}
if (Stream_GetRemainingLength(s) < 2) if (Stream_GetRemainingLength(s) < 2)
{
WLog_ERR(TAG, "Stream short");
return FALSE; return FALSE;
}
Stream_Read_UINT16(s, numberOrders); /* numberOrders (2 bytes) */ Stream_Read_UINT16(s, numberOrders); /* numberOrders (2 bytes) */

File diff suppressed because it is too large Load Diff

View File

@ -337,6 +337,7 @@ rdpSettings* freerdp_settings_new(DWORD flags)
settings->FIPSMode = FALSE; settings->FIPSMode = FALSE;
settings->CompressionEnabled = TRUE; settings->CompressionEnabled = TRUE;
settings->LogonNotify = TRUE; settings->LogonNotify = TRUE;
settings->BrushSupportLevel = BRUSH_COLOR_FULL;
if (settings->ServerMode) if (settings->ServerMode)
settings->CompressionLevel = PACKET_COMPR_TYPE_RDP61; settings->CompressionLevel = PACKET_COMPR_TYPE_RDP61;
@ -390,23 +391,23 @@ rdpSettings* freerdp_settings_new(DWORD flags)
settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE; settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE;
settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] = TRUE; settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] = TRUE;
settings->OrderSupport[NEG_DRAWNINEGRID_INDEX] = TRUE; settings->OrderSupport[NEG_DRAWNINEGRID_INDEX] = TRUE;
settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = TRUE; settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE;
settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = TRUE; settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE;
settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = TRUE; settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE;
settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = TRUE; settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = TRUE;
settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = TRUE; settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = FALSE;
settings->OrderSupport[NEG_LINETO_INDEX] = TRUE; settings->OrderSupport[NEG_LINETO_INDEX] = TRUE;
settings->OrderSupport[NEG_POLYLINE_INDEX] = TRUE; settings->OrderSupport[NEG_POLYLINE_INDEX] = TRUE;
settings->OrderSupport[NEG_MEMBLT_INDEX] = TRUE; settings->OrderSupport[NEG_MEMBLT_INDEX] = TRUE;
settings->OrderSupport[NEG_MEM3BLT_INDEX] = TRUE; settings->OrderSupport[NEG_MEM3BLT_INDEX] = TRUE;
settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = TRUE; settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE;
settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE; settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = FALSE;
settings->OrderSupport[NEG_FAST_INDEX_INDEX] = TRUE; settings->OrderSupport[NEG_FAST_INDEX_INDEX] = FALSE;
settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = TRUE; settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = FALSE;
settings->OrderSupport[NEG_POLYGON_SC_INDEX] = TRUE; settings->OrderSupport[NEG_POLYGON_SC_INDEX] = FALSE;
settings->OrderSupport[NEG_POLYGON_CB_INDEX] = TRUE; settings->OrderSupport[NEG_POLYGON_CB_INDEX] = FALSE;
settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = TRUE; settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE;
settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = TRUE; settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE;
settings->ClientProductId = calloc(1, 32); settings->ClientProductId = calloc(1, 32);
if (!settings->ClientProductId) if (!settings->ClientProductId)

View File

@ -33,7 +33,7 @@
BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string) BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
{ {
UINT16 new_len; UINT16 new_len;
BYTE *new_str; BYTE* new_str;
if (Stream_GetRemainingLength(s) < 2) if (Stream_GetRemainingLength(s) < 2)
return FALSE; return FALSE;
@ -52,9 +52,10 @@ BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
} }
new_str = (BYTE*) realloc(unicode_string->string, new_len); new_str = (BYTE*) realloc(unicode_string->string, new_len);
if (!new_str) if (!new_str)
{ {
free (unicode_string->string); free(unicode_string->string);
unicode_string->string = NULL; unicode_string->string = NULL;
return FALSE; return FALSE;
} }
@ -62,7 +63,6 @@ BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
unicode_string->string = new_str; unicode_string->string = new_str;
unicode_string->length = new_len; unicode_string->length = new_len;
Stream_Read(s, unicode_string->string, unicode_string->length); Stream_Read(s, unicode_string->string, unicode_string->length);
return TRUE; return TRUE;
} }
@ -110,14 +110,15 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* iconInfo)
/* bitsMask */ /* bitsMask */
newBitMask = (BYTE*) realloc(iconInfo->bitsMask, iconInfo->cbBitsMask); newBitMask = (BYTE*) realloc(iconInfo->bitsMask, iconInfo->cbBitsMask);
if (!newBitMask) if (!newBitMask)
{ {
free (iconInfo->bitsMask); free(iconInfo->bitsMask);
iconInfo->bitsMask = NULL; iconInfo->bitsMask = NULL;
return FALSE; return FALSE;
} }
iconInfo->bitsMask = newBitMask;
iconInfo->bitsMask = newBitMask;
Stream_Read(s, iconInfo->bitsMask, iconInfo->cbBitsMask); Stream_Read(s, iconInfo->bitsMask, iconInfo->cbBitsMask);
/* colorTable */ /* colorTable */
@ -126,21 +127,23 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* iconInfo)
if (iconInfo->cbColorTable) if (iconInfo->cbColorTable)
{ {
iconInfo->colorTable = (BYTE*) malloc(iconInfo->cbColorTable); iconInfo->colorTable = (BYTE*) malloc(iconInfo->cbColorTable);
if (!iconInfo->colorTable) if (!iconInfo->colorTable)
return FALSE; return FALSE;
} }
} }
else if (iconInfo->cbColorTable) else if (iconInfo->cbColorTable)
{ {
BYTE *new_tab; BYTE* new_tab;
new_tab = (BYTE*) realloc(iconInfo->colorTable, iconInfo->cbColorTable); new_tab = (BYTE*) realloc(iconInfo->colorTable, iconInfo->cbColorTable);
if (!new_tab) if (!new_tab)
{ {
free (iconInfo->colorTable); free(iconInfo->colorTable);
iconInfo->colorTable = NULL; iconInfo->colorTable = NULL;
return FALSE; return FALSE;
} }
iconInfo->colorTable = new_tab; iconInfo->colorTable = new_tab;
} }
else else
@ -153,17 +156,17 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* iconInfo)
Stream_Read(s, iconInfo->colorTable, iconInfo->cbColorTable); Stream_Read(s, iconInfo->colorTable, iconInfo->cbColorTable);
/* bitsColor */ /* bitsColor */
newBitMask = (BYTE *)realloc(iconInfo->bitsColor, iconInfo->cbBitsColor); newBitMask = (BYTE*)realloc(iconInfo->bitsColor, iconInfo->cbBitsColor);
if (!newBitMask) if (!newBitMask)
{ {
free (iconInfo->bitsColor); free(iconInfo->bitsColor);
iconInfo->bitsColor = NULL; iconInfo->bitsColor = NULL;
return FALSE; return FALSE;
} }
iconInfo->bitsColor = newBitMask; iconInfo->bitsColor = newBitMask;
Stream_Read(s, iconInfo->bitsColor, iconInfo->cbBitsColor); Stream_Read(s, iconInfo->bitsColor, iconInfo->cbBitsColor);
return TRUE; return TRUE;
} }
@ -174,7 +177,6 @@ BOOL update_read_cached_icon_info(wStream* s, CACHED_ICON_INFO* cachedIconInfo)
Stream_Read_UINT16(s, cachedIconInfo->cacheEntry); /* cacheEntry (2 bytes) */ Stream_Read_UINT16(s, cachedIconInfo->cacheEntry); /* cacheEntry (2 bytes) */
Stream_Read_UINT8(s, cachedIconInfo->cacheId); /* cacheId (1 byte) */ Stream_Read_UINT8(s, cachedIconInfo->cacheId); /* cacheId (1 byte) */
return TRUE; return TRUE;
} }
@ -185,12 +187,12 @@ BOOL update_read_notify_icon_infotip(wStream* s, NOTIFY_ICON_INFOTIP* notifyIcon
Stream_Read_UINT32(s, notifyIconInfoTip->timeout); /* timeout (4 bytes) */ Stream_Read_UINT32(s, notifyIconInfoTip->timeout); /* timeout (4 bytes) */
Stream_Read_UINT32(s, notifyIconInfoTip->flags); /* infoFlags (4 bytes) */ Stream_Read_UINT32(s, notifyIconInfoTip->flags); /* infoFlags (4 bytes) */
return rail_read_unicode_string(s, &notifyIconInfoTip->text) && /* infoTipText */ return rail_read_unicode_string(s, &notifyIconInfoTip->text) && /* infoTipText */
rail_read_unicode_string(s, &notifyIconInfoTip->title); /* title */ rail_read_unicode_string(s, &notifyIconInfoTip->title); /* title */
} }
BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* windowState) BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo,
WINDOW_STATE_ORDER* windowState)
{ {
int i; int i;
int size; int size;
@ -295,18 +297,21 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
Stream_Read_UINT16(s, windowState->numWindowRects); /* numWindowRects (2 bytes) */ Stream_Read_UINT16(s, windowState->numWindowRects); /* numWindowRects (2 bytes) */
if (windowState->numWindowRects == 0) { if (windowState->numWindowRects == 0)
{
return TRUE; return TRUE;
} }
size = sizeof(RECTANGLE_16) * windowState->numWindowRects; size = sizeof(RECTANGLE_16) * windowState->numWindowRects;
newRect = (RECTANGLE_16*)realloc(windowState->windowRects, size); newRect = (RECTANGLE_16*)realloc(windowState->windowRects, size);
if (!newRect) if (!newRect)
{ {
free(windowState->windowRects); free(windowState->windowRects);
windowState->windowRects = NULL; windowState->windowRects = NULL;
return FALSE; return FALSE;
} }
windowState->windowRects = newRect; windowState->windowRects = newRect;
if (Stream_GetRemainingLength(s) < 8 * windowState->numWindowRects) if (Stream_GetRemainingLength(s) < 8 * windowState->numWindowRects)
@ -338,17 +343,21 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
Stream_Read_UINT16(s, windowState->numVisibilityRects); /* numVisibilityRects (2 bytes) */ Stream_Read_UINT16(s, windowState->numVisibilityRects); /* numVisibilityRects (2 bytes) */
if (windowState->numVisibilityRects == 0) { if (windowState->numVisibilityRects == 0)
{
return TRUE; return TRUE;
} }
size = sizeof(RECTANGLE_16) * windowState->numVisibilityRects; size = sizeof(RECTANGLE_16) * windowState->numVisibilityRects;
newRect = (RECTANGLE_16*)realloc(windowState->visibilityRects, size); newRect = (RECTANGLE_16*)realloc(windowState->visibilityRects, size);
if (!newRect) if (!newRect)
{ {
free(windowState->visibilityRects); free(windowState->visibilityRects);
windowState->visibilityRects = NULL; windowState->visibilityRects = NULL;
return FALSE; return FALSE;
} }
windowState->visibilityRects = newRect; windowState->visibilityRects = newRect;
if (Stream_GetRemainingLength(s) < windowState->numVisibilityRects * 8) if (Stream_GetRemainingLength(s) < windowState->numVisibilityRects * 8)
@ -363,22 +372,27 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
Stream_Read_UINT16(s, windowState->visibilityRects[i].bottom); /* bottom (2 bytes) */ Stream_Read_UINT16(s, windowState->visibilityRects[i].bottom); /* bottom (2 bytes) */
} }
} }
return TRUE; return TRUE;
} }
BOOL update_read_window_icon_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WINDOW_ICON_ORDER* window_icon) BOOL update_read_window_icon_order(wStream* s, WINDOW_ORDER_INFO* orderInfo,
WINDOW_ICON_ORDER* window_icon)
{ {
update_free_window_icon_info(window_icon->iconInfo); update_free_window_icon_info(window_icon->iconInfo);
window_icon->iconInfo = (ICON_INFO*) calloc(1, sizeof(ICON_INFO)); window_icon->iconInfo = (ICON_INFO*) calloc(1, sizeof(ICON_INFO));
if (!window_icon->iconInfo) if (!window_icon->iconInfo)
return FALSE; return FALSE;
return update_read_icon_info(s, window_icon->iconInfo); /* iconInfo (ICON_INFO) */ return update_read_icon_info(s, window_icon->iconInfo); /* iconInfo (ICON_INFO) */
} }
BOOL update_read_window_cached_icon_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WINDOW_CACHED_ICON_ORDER* window_cached_icon) BOOL update_read_window_cached_icon_order(wStream* s, WINDOW_ORDER_INFO* orderInfo,
WINDOW_CACHED_ICON_ORDER* window_cached_icon)
{ {
return update_read_cached_icon_info(s, &window_cached_icon->cachedIcon); /* cachedIcon (CACHED_ICON_INFO) */ return update_read_cached_icon_info(s,
&window_cached_icon->cachedIcon); /* cachedIcon (CACHED_ICON_INFO) */
} }
void update_read_window_delete_order(wStream* s, WINDOW_ORDER_INFO* orderInfo) void update_read_window_delete_order(wStream* s, WINDOW_ORDER_INFO* orderInfo)
@ -401,6 +415,7 @@ BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_I
{ {
if (!update_read_window_icon_order(s, orderInfo, &window->window_icon)) if (!update_read_window_icon_order(s, orderInfo, &window->window_icon))
return FALSE; return FALSE;
WLog_Print(update->log, WLOG_DEBUG, "WindowIcon"); WLog_Print(update->log, WLOG_DEBUG, "WindowIcon");
IFCALLRET(window->WindowIcon, result, context, orderInfo, &window->window_icon); IFCALLRET(window->WindowIcon, result, context, orderInfo, &window->window_icon);
} }
@ -408,6 +423,7 @@ BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_I
{ {
if (!update_read_window_cached_icon_order(s, orderInfo, &window->window_cached_icon)) if (!update_read_window_cached_icon_order(s, orderInfo, &window->window_cached_icon))
return FALSE; return FALSE;
WLog_Print(update->log, WLOG_DEBUG, "WindowCachedIcon"); WLog_Print(update->log, WLOG_DEBUG, "WindowCachedIcon");
IFCALLRET(window->WindowCachedIcon, result, context, orderInfo, &window->window_cached_icon); IFCALLRET(window->WindowCachedIcon, result, context, orderInfo, &window->window_cached_icon);
} }
@ -437,12 +453,14 @@ BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_I
return result; return result;
} }
BOOL update_read_notification_icon_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notify_icon_state) BOOL update_read_notification_icon_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo,
NOTIFY_ICON_STATE_ORDER* notify_icon_state)
{ {
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION) if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION)
{ {
if (Stream_GetRemainingLength(s) < 4) if (Stream_GetRemainingLength(s) < 4)
return FALSE; return FALSE;
Stream_Read_UINT32(s, notify_icon_state->version); /* version (4 bytes) */ Stream_Read_UINT32(s, notify_icon_state->version); /* version (4 bytes) */
} }
@ -454,7 +472,8 @@ BOOL update_read_notification_icon_state_order(wStream* s, WINDOW_ORDER_INFO* or
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP) if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP)
{ {
if (!update_read_notify_icon_infotip(s, &notify_icon_state->infoTip)) /* infoTip (NOTIFY_ICON_INFOTIP) */ if (!update_read_notify_icon_infotip(s,
&notify_icon_state->infoTip)) /* infoTip (NOTIFY_ICON_INFOTIP) */
return FALSE; return FALSE;
} }
@ -474,7 +493,8 @@ BOOL update_read_notification_icon_state_order(wStream* s, WINDOW_ORDER_INFO* or
if (orderInfo->fieldFlags & WINDOW_ORDER_CACHED_ICON) if (orderInfo->fieldFlags & WINDOW_ORDER_CACHED_ICON)
{ {
if (!update_read_cached_icon_info(s, &notify_icon_state->cachedIcon)) /* cachedIcon (CACHED_ICON_INFO) */ if (!update_read_cached_icon_info(s,
&notify_icon_state->cachedIcon)) /* cachedIcon (CACHED_ICON_INFO) */
return FALSE; return FALSE;
} }
@ -486,7 +506,8 @@ void update_read_notification_icon_delete_order(wStream* s, WINDOW_ORDER_INFO* o
/* notification icon deletion event */ /* notification icon deletion event */
} }
BOOL update_recv_notification_icon_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_INFO* orderInfo) BOOL update_recv_notification_icon_info_order(rdpUpdate* update, wStream* s,
WINDOW_ORDER_INFO* orderInfo)
{ {
rdpContext* context = update->context; rdpContext* context = update->context;
rdpWindowUpdate* window = update->window; rdpWindowUpdate* window = update->window;
@ -524,7 +545,8 @@ BOOL update_recv_notification_icon_info_order(rdpUpdate* update, wStream* s, WIN
return result; return result;
} }
BOOL update_read_desktop_actively_monitored_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, MONITORED_DESKTOP_ORDER* monitored_desktop) BOOL update_read_desktop_actively_monitored_order(wStream* s, WINDOW_ORDER_INFO* orderInfo,
MONITORED_DESKTOP_ORDER* monitored_desktop)
{ {
int i; int i;
int size; int size;
@ -539,7 +561,7 @@ BOOL update_read_desktop_actively_monitored_order(wStream* s, WINDOW_ORDER_INFO*
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER) if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
{ {
UINT32 *newid; UINT32* newid;
if (Stream_GetRemainingLength(s) < 1) if (Stream_GetRemainingLength(s) < 1)
return FALSE; return FALSE;
@ -549,16 +571,18 @@ BOOL update_read_desktop_actively_monitored_order(wStream* s, WINDOW_ORDER_INFO*
if (Stream_GetRemainingLength(s) < 4 * monitored_desktop->numWindowIds) if (Stream_GetRemainingLength(s) < 4 * monitored_desktop->numWindowIds)
return FALSE; return FALSE;
if (monitored_desktop->numWindowIds > 0) { if (monitored_desktop->numWindowIds > 0)
{
size = sizeof(UINT32) * monitored_desktop->numWindowIds; size = sizeof(UINT32) * monitored_desktop->numWindowIds;
newid = (UINT32*)realloc(monitored_desktop->windowIds, size); newid = (UINT32*)realloc(monitored_desktop->windowIds, size);
if (!newid) if (!newid)
{ {
free(monitored_desktop->windowIds); free(monitored_desktop->windowIds);
monitored_desktop->windowIds = NULL; monitored_desktop->windowIds = NULL;
return FALSE; return FALSE;
} }
monitored_desktop->windowIds = newid; monitored_desktop->windowIds = newid;
/* windowIds */ /* windowIds */
@ -593,6 +617,7 @@ BOOL update_recv_desktop_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_
{ {
if (!update_read_desktop_actively_monitored_order(s, orderInfo, &window->monitored_desktop)) if (!update_read_desktop_actively_monitored_order(s, orderInfo, &window->monitored_desktop))
return FALSE; return FALSE;
WLog_Print(update->log, WLOG_DEBUG, "ActivelyMonitoredDesktop"); WLog_Print(update->log, WLOG_DEBUG, "ActivelyMonitoredDesktop");
IFCALLRET(window->MonitoredDesktop, result, context, orderInfo, &window->monitored_desktop); IFCALLRET(window->MonitoredDesktop, result, context, orderInfo, &window->monitored_desktop);
} }
@ -602,39 +627,44 @@ BOOL update_recv_desktop_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_
void update_free_window_icon_info(ICON_INFO* iconInfo) void update_free_window_icon_info(ICON_INFO* iconInfo)
{ {
if (!iconInfo) if (!iconInfo)
return; return;
free(iconInfo->bitsColor);
iconInfo->bitsColor = NULL;
free(iconInfo->bitsMask);
iconInfo->bitsMask = NULL;
free(iconInfo->colorTable);
iconInfo->colorTable = NULL;
free(iconInfo->bitsColor);
iconInfo->bitsColor = NULL;
free(iconInfo->bitsMask);
iconInfo->bitsMask = NULL;
free(iconInfo->colorTable);
iconInfo->colorTable = NULL;
free(iconInfo); free(iconInfo);
} }
BOOL update_recv_altsec_window_order(rdpUpdate* update, wStream* s) BOOL update_recv_altsec_window_order(rdpUpdate* update, wStream* s)
{ {
BOOL rc = TRUE;
UINT16 orderSize; UINT16 orderSize;
rdpWindowUpdate* window = update->window; rdpWindowUpdate* window = update->window;
if (Stream_GetRemainingLength(s) < 6) if (Stream_GetRemainingLength(s) < 6)
{
WLog_Print(update->log, WLOG_ERROR, "Stream short");
return FALSE; return FALSE;
}
Stream_Read_UINT16(s, orderSize); /* orderSize (2 bytes) */ Stream_Read_UINT16(s, orderSize); /* orderSize (2 bytes) */
Stream_Read_UINT32(s, window->orderInfo.fieldFlags); /* FieldsPresentFlags (4 bytes) */ Stream_Read_UINT32(s, window->orderInfo.fieldFlags); /* FieldsPresentFlags (4 bytes) */
if (window->orderInfo.fieldFlags & WINDOW_ORDER_TYPE_WINDOW) if (window->orderInfo.fieldFlags & WINDOW_ORDER_TYPE_WINDOW)
return update_recv_window_info_order(update, s, &window->orderInfo); rc = update_recv_window_info_order(update, s, &window->orderInfo);
else if (window->orderInfo.fieldFlags & WINDOW_ORDER_TYPE_NOTIFY) else if (window->orderInfo.fieldFlags & WINDOW_ORDER_TYPE_NOTIFY)
return update_recv_notification_icon_info_order(update, s, &window->orderInfo); rc = update_recv_notification_icon_info_order(update, s, &window->orderInfo);
else if (window->orderInfo.fieldFlags & WINDOW_ORDER_TYPE_DESKTOP) else if (window->orderInfo.fieldFlags & WINDOW_ORDER_TYPE_DESKTOP)
return update_recv_desktop_info_order(update, s, &window->orderInfo); rc = update_recv_desktop_info_order(update, s, &window->orderInfo);
return TRUE; if (!rc)
WLog_Print(update->log, WLOG_ERROR, "windoworder flags %08"PRIx32" failed",
window->orderInfo.fieldFlags);
return rc;
} }

View File

@ -56,7 +56,7 @@ INLINE UINT32 gdi_GetPixel(HGDI_DC hdc, UINT32 nXPos, UINT32 nYPos)
{ {
HGDI_BITMAP hBmp = (HGDI_BITMAP) hdc->selectedObject; HGDI_BITMAP hBmp = (HGDI_BITMAP) hdc->selectedObject;
BYTE* data = &(hBmp->data[(nYPos * hBmp->scanline) + nXPos * GetBytesPerPixel( BYTE* data = &(hBmp->data[(nYPos * hBmp->scanline) + nXPos * GetBytesPerPixel(
hBmp->format)]); hBmp->format)]);
return ReadColor(data, hBmp->format); return ReadColor(data, hBmp->format);
} }
@ -80,7 +80,7 @@ static INLINE UINT32 gdi_SetPixelBmp(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y,
UINT32 crColor) UINT32 crColor)
{ {
BYTE* p = &hBmp->data[(Y * hBmp->scanline) + X * GetBytesPerPixel( BYTE* p = &hBmp->data[(Y * hBmp->scanline) + X * GetBytesPerPixel(
hBmp->format)]; hBmp->format)];
WriteColor(p, hBmp->format, crColor); WriteColor(p, hBmp->format, crColor);
return crColor; return crColor;
} }
@ -480,9 +480,15 @@ BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
switch (rop) switch (rop)
{ {
case GDI_SRCCOPY: case GDI_SRCCOPY:
if (!hdcSrc)
return FALSE;
hSrcBmp = (HGDI_BITMAP) hdcSrc->selectedObject; hSrcBmp = (HGDI_BITMAP) hdcSrc->selectedObject;
hDstBmp = (HGDI_BITMAP) hdcDest->selectedObject; hDstBmp = (HGDI_BITMAP) hdcDest->selectedObject;
if (!hSrcBmp || !hDstBmp)
return FALSE;
if (!freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline, if (!freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline,
nXDest, nYDest, nWidth, nHeight, nXDest, nYDest, nWidth, nHeight,
hSrcBmp->data, hSrcBmp->format, hSrcBmp->scanline, nXSrc, nYSrc, palette, FREERDP_FLIP_NONE)) hSrcBmp->data, hSrcBmp->format, hSrcBmp->scanline, nXSrc, nYSrc, palette, FREERDP_FLIP_NONE))
@ -494,6 +500,9 @@ BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
hSrcBmp = (HGDI_BITMAP) hdcDest->selectedObject; hSrcBmp = (HGDI_BITMAP) hdcDest->selectedObject;
hDstBmp = (HGDI_BITMAP) hdcDest->selectedObject; hDstBmp = (HGDI_BITMAP) hdcDest->selectedObject;
if (!hSrcBmp || !hDstBmp)
return FALSE;
if (!freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline, if (!freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline,
nXDest, nYDest, nWidth, nHeight, nXDest, nYDest, nWidth, nHeight,
hSrcBmp->data, hSrcBmp->format, hSrcBmp->scanline, nXSrc, nYSrc, palette, FREERDP_FLIP_NONE)) hSrcBmp->data, hSrcBmp->format, hSrcBmp->scanline, nXSrc, nYSrc, palette, FREERDP_FLIP_NONE))

View File

@ -574,7 +574,7 @@ static BOOL gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
gdi_rop3_code(dstblt->bRop), &gdi->palette); gdi_rop3_code(dstblt->bRop), &gdi->palette);
} }
static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) static BOOL gdi_patblt(rdpContext* context, const PATBLT_ORDER* patblt)
{ {
const rdpBrush* brush = &patblt->brush; const rdpBrush* brush = &patblt->brush;
UINT32 foreColor; UINT32 foreColor;
@ -663,9 +663,7 @@ static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
break; break;
} }
if (!hbrush) if (hbrush)
gdi_DeleteObject((HGDIOBJECT) hBmp);
else
{ {
hbrush->nXOrg = brush->x; hbrush->nXOrg = brush->x;
hbrush->nYOrg = brush->y; hbrush->nYOrg = brush->y;
@ -676,6 +674,7 @@ static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
} }
out_error: out_error:
gdi_DeleteObject((HGDIOBJECT) hBmp);
gdi_DeleteObject((HGDIOBJECT) hbrush); gdi_DeleteObject((HGDIOBJECT) hbrush);
gdi->drawing->hdc->brush = originalBrush; gdi->drawing->hdc->brush = originalBrush;
gdi_SetTextColor(gdi->drawing->hdc, originalColor); gdi_SetTextColor(gdi->drawing->hdc, originalColor);
@ -933,6 +932,7 @@ static BOOL gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop), mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop),
&gdi->palette); &gdi->palette);
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush); gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
gdi_DeleteObject((HGDIOBJECT) hBmp);
gdi->drawing->hdc->brush = originalBrush; gdi->drawing->hdc->brush = originalBrush;
} }
break; break;

View File

@ -112,10 +112,11 @@ static void gdi_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
if (gdi_bitmap) if (gdi_bitmap)
{ {
gdi_SelectObject(gdi_bitmap->hdc, (HGDIOBJECT) gdi_bitmap->org_bitmap); if (gdi_bitmap->hdc)
gdi_SelectObject(gdi_bitmap->hdc, (HGDIOBJECT) gdi_bitmap->org_bitmap);
gdi_DeleteObject((HGDIOBJECT) gdi_bitmap->bitmap); gdi_DeleteObject((HGDIOBJECT) gdi_bitmap->bitmap);
gdi_DeleteDC(gdi_bitmap->hdc); gdi_DeleteDC(gdi_bitmap->hdc);
_aligned_free(bitmap->data); _aligned_free(bitmap->data);
} }
@ -139,7 +140,6 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
UINT32 codecId) UINT32 codecId)
{ {
UINT32 SrcSize = length; UINT32 SrcSize = length;
UINT32 SrcFormat;
rdpGdi* gdi = context->gdi; rdpGdi* gdi = context->gdi;
bitmap->compressed = FALSE; bitmap->compressed = FALSE;
bitmap->format = gdi->dstFormat; bitmap->format = gdi->dstFormat;
@ -173,7 +173,19 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
} }
else else
{ {
SrcFormat = gdi_get_pixel_format(bpp); const UINT32 SrcFormat = gdi_get_pixel_format(bpp);
const size_t sbpp = GetBytesPerPixel(SrcFormat);
const size_t dbpp = GetBytesPerPixel(bitmap->format);
if ((sbpp == 0) || (dbpp == 0))
return FALSE;
else
{
const size_t dstSize = SrcSize * dbpp / sbpp;
if (dstSize < bitmap->length)
return FALSE;
}
if (!freerdp_image_copy(bitmap->data, bitmap->format, 0, 0, 0, if (!freerdp_image_copy(bitmap->data, bitmap->format, 0, 0, 0,
DstWidth, DstHeight, pSrcData, SrcFormat, DstWidth, DstHeight, pSrcData, SrcFormat,
@ -193,6 +205,7 @@ static BOOL gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
return FALSE; return FALSE;
gdi = context->gdi; gdi = context->gdi;
if (!gdi) if (!gdi)
return FALSE; return FALSE;