diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2016-12-14 23:55:13 -0800 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2016-12-14 23:55:13 -0800 |
commit | 492116d535173eeb7c8008f6687cd82ee60165f4 (patch) | |
tree | 3f5d03b98d9d4e3f6e09d69bd20cce26d3b73c1b /libxrdp/xrdp_orders.c | |
parent | 4462d22bf16f17a1561b529a5970cbf93d4a9458 (diff) | |
download | xrdp-proprietary-492116d535173eeb7c8008f6687cd82ee60165f4.tar.gz xrdp-proprietary-492116d535173eeb7c8008f6687cd82ee60165f4.zip |
fixes for rle bitmap compress limits and raw bitmaps
Diffstat (limited to 'libxrdp/xrdp_orders.c')
-rw-r--r-- | libxrdp/xrdp_orders.c | 115 |
1 files changed, 77 insertions, 38 deletions
diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index 18a5ad38..b0c28ed8 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -2235,6 +2235,11 @@ xrdp_orders_send_raw_bitmap(struct xrdp_orders *self, Bpp = (bpp + 7) / 8; bufsize = (width + e) * height * Bpp; + while (bufsize + 16 > MAX_ORDERS_SIZE) + { + height--; + bufsize = (width + e) * height * Bpp; + } if (xrdp_orders_check(self, bufsize + 16) != 0) { return 1; @@ -2254,33 +2259,58 @@ xrdp_orders_send_raw_bitmap(struct xrdp_orders *self, out_uint16_le(self->out_s, bufsize); out_uint16_le(self->out_s, cache_idx); - for (i = height - 1; i >= 0; i--) + if (Bpp == 4) { - for (j = 0; j < width; j++) + for (i = height - 1; i >= 0; i--) { - if (Bpp == 3) + for (j = 0; j < width; j++) { pixel = GETPIXEL32(data, j, i, width); out_uint8(self->out_s, pixel); out_uint8(self->out_s, pixel >> 8); out_uint8(self->out_s, pixel >> 16); + out_uint8(self->out_s, pixel >> 24); } - else if (Bpp == 2) + out_uint8s(self->out_s, Bpp * e); + } + } + else if (Bpp == 3) + { + for (i = height - 1; i >= 0; i--) + { + for (j = 0; j < width; j++) { - pixel = GETPIXEL16(data, j, i, width); + pixel = GETPIXEL32(data, j, i, width); out_uint8(self->out_s, pixel); out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel >> 16); } - else if (Bpp == 1) + out_uint8s(self->out_s, Bpp * e); + } + } + else if (Bpp == 2) + { + for (i = height - 1; i >= 0; i--) + { + for (j = 0; j < width; j++) { - pixel = GETPIXEL8(data, j, i, width); + pixel = GETPIXEL16(data, j, i, width); out_uint8(self->out_s, pixel); + out_uint8(self->out_s, pixel >> 8); } + out_uint8s(self->out_s, Bpp * e); } - - for (j = 0; j < e; j++) + } + else if (Bpp == 1) + { + for (i = height - 1; i >= 0; i--) { - out_uint8s(self->out_s, Bpp); + for (j = 0; j < width; j++) + { + pixel = GETPIXEL8(data, j, i, width); + out_uint8(self->out_s, pixel); + } + out_uint8s(self->out_s, Bpp * e); } } @@ -2334,20 +2364,19 @@ xrdp_orders_send_bitmap(struct xrdp_orders *self, if (bpp > 24) { lines_sending = xrdp_bitmap32_compress(data, width, height, s, - bpp, 16384, + bpp, MAX_ORDERS_SIZE, i - 1, temp_s, e, 0x10); } else { - lines_sending = xrdp_bitmap_compress(data, width, height, s, bpp, 16384, + lines_sending = xrdp_bitmap_compress(data, width, height, s, + bpp, MAX_ORDERS_SIZE, i - 1, temp_s, e); } if (lines_sending != height) { - g_writeln("error in xrdp_orders_send_bitmap, lines_sending(%d) != \ -height(%d)", lines_sending, height); - return 1; + height = lines_sending; } bufsize = (int)(s->p - p); @@ -2458,6 +2487,7 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self, int pixel = 0; int e = 0; + g_writeln("xrdp_orders_send_raw_bitmap2:"); if (width > 64) { g_writeln("error, width > 64"); @@ -2479,6 +2509,11 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self, Bpp = (bpp + 7) / 8; bufsize = (width + e) * height * Bpp; + while (bufsize + 14 > MAX_ORDERS_SIZE) + { + height--; + bufsize = (width + e) * height * Bpp; + } if (xrdp_orders_check(self, bufsize + 14) != 0) { return 1; @@ -2499,7 +2534,7 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self, i = cache_idx & 0xff; out_uint8(self->out_s, i); - if (1 && Bpp == 3) + if (Bpp == 4) { for (i = height - 1; i >= 0; i--) { @@ -2509,44 +2544,49 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self, out_uint8(self->out_s, pixel); out_uint8(self->out_s, pixel >> 8); out_uint8(self->out_s, pixel >> 16); + out_uint8(self->out_s, pixel >> 24); } - for (j = 0; j < e; j++) - { - out_uint8s(self->out_s, Bpp); - } + out_uint8s(self->out_s, Bpp * e); } } - else - { - for (i = height - 1; i >= 0; i--) + else if (Bpp == 3) { - for (j = 0; j < width; j++) + for (i = height - 1; i >= 0; i--) { - if (Bpp == 3) + for (j = 0; j < width; j++) { pixel = GETPIXEL32(data, j, i, width); out_uint8(self->out_s, pixel); out_uint8(self->out_s, pixel >> 8); out_uint8(self->out_s, pixel >> 16); } - else if (Bpp == 2) + out_uint8s(self->out_s, Bpp * e); + } + } + else if (Bpp == 2) + { + for (i = height - 1; i >= 0; i--) + { + for (j = 0; j < width; j++) { pixel = GETPIXEL16(data, j, i, width); out_uint8(self->out_s, pixel); out_uint8(self->out_s, pixel >> 8); } - else if (Bpp == 1) + out_uint8s(self->out_s, Bpp * e); + } + } + else if (Bpp == 1) + { + for (i = height - 1; i >= 0; i--) + { + for (j = 0; j < width; j++) { pixel = GETPIXEL8(data, j, i, width); out_uint8(self->out_s, pixel); } + out_uint8s(self->out_s, Bpp * e); } - - for (j = 0; j < e; j++) - { - out_uint8s(self->out_s, Bpp); - } - } } return 0; @@ -2599,20 +2639,19 @@ xrdp_orders_send_bitmap2(struct xrdp_orders *self, if (bpp > 24) { lines_sending = xrdp_bitmap32_compress(data, width, height, s, - bpp, 16384, + bpp, MAX_ORDERS_SIZE, i - 1, temp_s, e, 0x10); } else { - lines_sending = xrdp_bitmap_compress(data, width, height, s, bpp, 16384, + lines_sending = xrdp_bitmap_compress(data, width, height, s, + bpp, MAX_ORDERS_SIZE, i - 1, temp_s, e); } if (lines_sending != height) { - g_writeln("error in xrdp_orders_send_bitmap2, lines_sending(%d) != \ -height(%d)", lines_sending, height); - return 1; + height = lines_sending; } bufsize = (int)(s->p - p); |