From f88ed950d3099a327a64bc18218ac27eaef0653c Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 15 Oct 2018 14:30:38 +0200 Subject: [PATCH] Fixed various issues with primary orders. --- client/X11/xf_client.c | 12 +++++----- include/freerdp/primary.h | 2 +- libfreerdp/core/fastpath.c | 9 +++++++ libfreerdp/core/orders.c | 49 +++++++++++++++++++++++++++++++++----- libfreerdp/core/settings.c | 18 +++++++------- 5 files changed, 68 insertions(+), 22 deletions(-) diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 104d24943..eceaab66a 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -1096,9 +1096,9 @@ static BOOL xf_pre_connect(freerdp* instance) settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE; settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] = TRUE; settings->OrderSupport[NEG_DRAWNINEGRID_INDEX] = FALSE; - settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE; - settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE; - settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE; + settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = TRUE; + settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = TRUE; + settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = TRUE; settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = TRUE; settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = FALSE; settings->OrderSupport[NEG_LINETO_INDEX] = TRUE; @@ -1108,9 +1108,9 @@ static BOOL xf_pre_connect(freerdp* instance) settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = settings->BitmapCacheEnabled; settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = settings->BitmapCacheEnabled; settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE; - settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE; - settings->OrderSupport[NEG_FAST_INDEX_INDEX] = TRUE; - settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = TRUE; + settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = FALSE; + settings->OrderSupport[NEG_FAST_INDEX_INDEX] = FALSE; + settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = FALSE; settings->OrderSupport[NEG_POLYGON_SC_INDEX] = FALSE; settings->OrderSupport[NEG_POLYGON_CB_INDEX] = FALSE; settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE; diff --git a/include/freerdp/primary.h b/include/freerdp/primary.h index 3ed07a776..a1f810fdb 100644 --- a/include/freerdp/primary.h +++ b/include/freerdp/primary.h @@ -212,7 +212,7 @@ struct _MULTI_DRAW_NINE_GRID_ORDER UINT32 bitmapId; UINT32 nDeltaEntries; UINT32 cbData; - BYTE* codeDeltaList; + DELTA_RECT rectangles[45]; }; typedef struct _MULTI_DRAW_NINE_GRID_ORDER MULTI_DRAW_NINE_GRID_ORDER; diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index c3506063c..b09a18fea 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -265,15 +265,24 @@ static BOOL fastpath_recv_orders(rdpFastPath* fastpath, wStream* s) UINT16 numberOrders; if (!fastpath || !fastpath->rdp || !s) + { + WLog_ERR(TAG, "Invalid arguments"); return FALSE; + } update = fastpath->rdp->update; if (!update) + { + WLog_ERR(TAG, "Invalid configuration"); return FALSE; + } if (Stream_GetRemainingLength(s) < 2) + { + WLog_ERR(TAG, "Stream short"); return FALSE; + } Stream_Read_UINT16(s, numberOrders); /* numberOrders (2 bytes) */ diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index a2e21ed21..f425a401a 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -319,7 +319,7 @@ static BOOL freerdp_check_point(rdpContext* context, INT32 x, INT32 y) if (x > dw) goto fail; - if (y > dw) + if (y > dh) goto fail; return TRUE; @@ -328,6 +328,35 @@ fail: return FALSE; } +static BOOL adjust_point(rdpContext* context, INT32* px, INT32* py) +{ + INT32 x, y; + UINT32 dw, dh; + + if (!context || !context->settings || !px || !py) + return FALSE; + + x = *px; + y = *py; + dw = context->settings->DesktopWidth; + dh = context->settings->DesktopHeight; + + if (x < 0) + x = 0; + + if (y < 0) + y = 0; + + if (x > dw) + x = dw; + + if (y > dh) + y = dh; + + *px = x; + *py = y; + return TRUE;; +} static BOOL freerdp_check_delta_point(rdpContext* context, INT32 x, INT32 y, UINT32 count, const DELTA_POINT* data) { @@ -1402,7 +1431,12 @@ static BOOL update_read_multi_draw_nine_grid_order(wStream* s, if (orderInfo->fieldFlags & ORDER_FIELD_07) { - FIELD_SKIP_BUFFER16(s, multi_draw_nine_grid->cbData); + if (Stream_GetRemainingLength(s) < 2) + return FALSE; + + Stream_Read_UINT16(s, multi_draw_nine_grid->cbData); + return update_read_delta_rects(s, multi_draw_nine_grid->rectangles, + multi_draw_nine_grid->nDeltaEntries); } return TRUE; @@ -3449,7 +3483,10 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) primary->multi_draw_nine_grid.srcBottom)) return FALSE; - // TODO: Delta rects + if (!freerdp_check_delta_rect(context, primary->multi_draw_nine_grid.nDeltaEntries, + primary->multi_draw_nine_grid.rectangles)) + return FALSE; + rc = IFCALLRESULT(FALSE, primary->MultiDrawNineGrid, context, &primary->multi_draw_nine_grid); break; @@ -3462,10 +3499,10 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); - if (!freerdp_check_point(context, primary->line_to.nXStart, primary->line_to.nYStart)) + if (!adjust_point(context, &primary->line_to.nXStart, &primary->line_to.nYStart)) return FALSE; - if (!freerdp_check_point(context, primary->line_to.nXEnd, primary->line_to.nYEnd)) + if (!adjust_point(context, &primary->line_to.nXEnd, &primary->line_to.nYEnd)) return FALSE; rc = IFCALLRESULT(FALSE, primary->LineTo, context, &primary->line_to); @@ -3604,7 +3641,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) primary->fast_glyph.opRight, primary->fast_index.opBottom)) return FALSE; - if (!freerdp_check_point(context, primary->fast_glyph.x, primary->fast_glyph.y)) + if (!adjust_point(context, &primary->fast_glyph.x, &primary->fast_glyph.y)) return FALSE; rc = IFCALLRESULT(FALSE, primary->FastGlyph, context, &primary->fast_glyph); diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index a49d0c60a..21b082175 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -394,19 +394,19 @@ rdpSettings* freerdp_settings_new(DWORD flags) settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = TRUE; settings->OrderSupport[NEG_MULTISCRBLT_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_POLYLINE_INDEX] = TRUE; settings->OrderSupport[NEG_MEMBLT_INDEX] = TRUE; settings->OrderSupport[NEG_MEM3BLT_INDEX] = TRUE; - settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = TRUE; - settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE; - settings->OrderSupport[NEG_FAST_INDEX_INDEX] = TRUE; - settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = TRUE; - settings->OrderSupport[NEG_POLYGON_SC_INDEX] = TRUE; - settings->OrderSupport[NEG_POLYGON_CB_INDEX] = TRUE; - settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = TRUE; - settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = TRUE; + settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE; + settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = FALSE; + settings->OrderSupport[NEG_FAST_INDEX_INDEX] = FALSE; + settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = FALSE; + settings->OrderSupport[NEG_POLYGON_SC_INDEX] = FALSE; + settings->OrderSupport[NEG_POLYGON_CB_INDEX] = FALSE; + settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE; + settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE; settings->ClientProductId = calloc(1, 32); if (!settings->ClientProductId)