From 2a65e70d08e2cc979dd5bc99de779b6b77985e90 Mon Sep 17 00:00:00 2001 From: "zihao.jiang" Date: Tue, 4 Jul 2017 23:48:07 +0800 Subject: [PATCH] server/shadow: Fix incorrect bitmap fragment update. Legacy bitmap update might fail with 'fast path update size (xxxxx) exceeds the client's maximum request size (xxxxx)' Original code might update last fragment with exceeded fragment size incorrectly. Fix the logic to prevent it. --- server/shadow/shadow_client.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index 2a330f763..b96207d03 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -1095,19 +1095,14 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, { newUpdateSize = updateSize + (bitmapData[i].bitmapLength + 16); - if ((newUpdateSize < maxUpdateSize) && ((i + 1) < k)) + if (newUpdateSize < maxUpdateSize) { CopyMemory(&fragBitmapData[j++], &bitmapData[i++], sizeof(BITMAP_DATA)); updateSize = newUpdateSize; } - else - { - if ((i + 1) >= k) - { - CopyMemory(&fragBitmapData[j++], &bitmapData[i++], sizeof(BITMAP_DATA)); - updateSize = newUpdateSize; - } + if ((newUpdateSize >= maxUpdateSize) || (i + 1) >= k) + { bitmapUpdate.count = bitmapUpdate.number = j; IFCALLRET(update->BitmapUpdate, ret, context, &bitmapUpdate);