diff options
Diffstat (limited to 'libxrdp')
| -rw-r--r-- | libxrdp/libxrdp.c | 93 | ||||
| -rw-r--r-- | libxrdp/libxrdpinc.h | 2 | ||||
| -rw-r--r-- | libxrdp/xrdp_mcs.c | 35 | ||||
| -rw-r--r-- | libxrdp/xrdp_orders.c | 8 | ||||
| -rw-r--r-- | libxrdp/xrdp_rdp.c | 40 | ||||
| -rw-r--r-- | libxrdp/xrdp_sec.c | 3 |
6 files changed, 143 insertions, 38 deletions
diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c index d4c9d372..19e8a2c6 100644 --- a/libxrdp/libxrdp.c +++ b/libxrdp/libxrdp.c @@ -417,44 +417,105 @@ libxrdp_send_bitmap(struct xrdp_session *session, int width, int height, /*****************************************************************************/ int EXPORT_CC libxrdp_send_pointer(struct xrdp_session *session, int cache_idx, - char *data, char *mask, int x, int y) + char *data, char *mask, int x, int y, int bpp) { struct stream *s; char *p; + tui16 *p16; + tui32 *p32; int i; int j; + int data_bytes; DEBUG(("libxrdp_send_pointer sending cursor")); + if (bpp == 0) + { + bpp = 24; + } + /* error check */ + if ((session->client_info->pointer_flags & 1) == 0) + { + if (bpp != 24) + { + g_writeln("libxrdp_send_pointer: error"); + return 1; + } + } + if ((bpp == 15) && (bpp != 16) && (bpp != 24) && (bpp != 32)) + { + g_writeln("libxrdp_send_pointer: error"); + return 1; + } make_stream(s); init_stream(s, 8192); xrdp_rdp_init_data((struct xrdp_rdp *)session->rdp, s); - out_uint16_le(s, RDP_POINTER_COLOR); - out_uint16_le(s, 0); /* pad */ + if ((session->client_info->pointer_flags & 1) == 0) + { + out_uint16_le(s, RDP_POINTER_COLOR); + out_uint16_le(s, 0); /* pad */ + data_bytes = 3072; + } + else + { + out_uint16_le(s, RDP_POINTER_POINTER); + out_uint16_le(s, 0); /* pad */ + out_uint16_le(s, bpp); + data_bytes = ((bpp + 7) / 8) * 32 * 32; + } out_uint16_le(s, cache_idx); /* cache_idx */ out_uint16_le(s, x); out_uint16_le(s, y); out_uint16_le(s, 32); out_uint16_le(s, 32); out_uint16_le(s, 128); - out_uint16_le(s, 3072); - p = data; + out_uint16_le(s, data_bytes); - for (i = 0; i < 32; i++) + switch (bpp) { - for (j = 0; j < 32; j++) - { - out_uint8(s, *p); - p++; - out_uint8(s, *p); - p++; - out_uint8(s, *p); - p++; - } + case 15: + case 16: + p16 = (tui16 *) data; + for (i = 0; i < 32; i++) + { + for (j = 0; j < 32; j++) + { + out_uint16_le(s, *p16); + p16++; + } + } + break; + case 24: + p = data; + for (i = 0; i < 32; i++) + { + for (j = 0; j < 32; j++) + { + out_uint8(s, *p); + p++; + out_uint8(s, *p); + p++; + out_uint8(s, *p); + p++; + } + } + break; + case 32: + p32 = (tui32 *) data; + for (i = 0; i < 32; i++) + { + for (j = 0; j < 32; j++) + { + out_uint32_le(s, *p32); + p32++; + } + } + break; } out_uint8a(s, mask, 128); /* mask */ s_mark_end(s); - xrdp_rdp_send_data((struct xrdp_rdp *)session->rdp, s, RDP_DATA_PDU_POINTER); + xrdp_rdp_send_data((struct xrdp_rdp *)(session->rdp), s, + RDP_DATA_PDU_POINTER); free_stream(s); return 0; } diff --git a/libxrdp/libxrdpinc.h b/libxrdp/libxrdpinc.h index ebfc348c..9eac9733 100644 --- a/libxrdp/libxrdpinc.h +++ b/libxrdp/libxrdpinc.h @@ -91,7 +91,7 @@ libxrdp_send_bitmap(struct xrdp_session* session, int width, int height, int bpp, char* data, int x, int y, int cx, int cy); int DEFAULT_CC libxrdp_send_pointer(struct xrdp_session* session, int cache_idx, - char* data, char* mask, int x, int y); + char* data, char* mask, int x, int y, int bpp); int DEFAULT_CC libxrdp_set_pointer(struct xrdp_session* session, int cache_idx); int DEFAULT_CC diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c index 77c0d10d..dbcb0955 100644 --- a/libxrdp/xrdp_mcs.c +++ b/libxrdp/xrdp_mcs.c @@ -19,6 +19,7 @@ */ #include "libxrdp.h" +#include "log.h" /*****************************************************************************/ struct xrdp_mcs *APP_CC @@ -146,12 +147,12 @@ xrdp_mcs_recv(struct xrdp_mcs *self, struct stream *s, int *chan) { in_uint16_be(s, userid); in_uint16_be(s, chanid); - g_writeln("channel join request received %d:%d", userid, chanid); + log_message(LOG_LEVEL_DEBUG,"MCS_CJRQ - channel join request received"); DEBUG(("xrdp_mcs_recv adding channel %4.4x", chanid)); if (xrdp_mcs_send_cjcf(self, userid, chanid) != 0) { - g_writeln("Non handled error from xrdp_mcs_send_cjcf") ; + log_message(LOG_LEVEL_ERROR,"Non handled error from xrdp_mcs_send_cjcf") ; } continue; @@ -163,7 +164,7 @@ xrdp_mcs_recv(struct xrdp_mcs *self, struct stream *s, int *chan) } else { - g_writeln("Recieved an unhandled appid:%d", appid); + log_message(LOG_LEVEL_DEBUG,"Recieved an unhandled appid:%d",appid); } break; @@ -819,6 +820,25 @@ xrdp_mcs_send(struct xrdp_mcs *self, struct stream *s, int chan) return 0; } +/** + * Internal help function to close the socket + * @param self + */ +void close_rdp_socket(struct xrdp_mcs *self) +{ + if(self->iso_layer->tcp_layer) + { + if(self->iso_layer->tcp_layer->trans) + { + g_tcp_close(self->iso_layer->tcp_layer->trans->sck); + self->iso_layer->tcp_layer->trans->sck = 0 ; + g_writeln("xrdp_mcs_disconnect - socket closed"); + return ; + } + } + g_writeln("Failed to close socket"); +} + /*****************************************************************************/ /* returns error */ int APP_CC @@ -833,7 +853,8 @@ xrdp_mcs_disconnect(struct xrdp_mcs *self) if (xrdp_iso_init(self->iso_layer, s) != 0) { free_stream(s); - DEBUG((" out xrdp_mcs_disconnect error")); + close_rdp_socket(self); + DEBUG((" out xrdp_mcs_disconnect error - 1")); return 1; } @@ -844,11 +865,13 @@ xrdp_mcs_disconnect(struct xrdp_mcs *self) if (xrdp_iso_send(self->iso_layer, s) != 0) { free_stream(s); - DEBUG((" out xrdp_mcs_disconnect error")); + close_rdp_socket(self); + DEBUG((" out xrdp_mcs_disconnect error - 2")); return 1; } free_stream(s); - DEBUG((" out xrdp_mcs_disconnect")); + close_rdp_socket(self); + DEBUG(("xrdp_mcs_disconnect - close sent")); return 0; } diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index bb95aa71..7a17759c 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -1872,9 +1872,9 @@ xrdp_orders_send_raw_bitmap(struct xrdp_orders *self, if (Bpp == 3) { pixel = GETPIXEL32(data, j, i, width); - out_uint8(self->out_s, pixel >> 16); - out_uint8(self->out_s, pixel >> 8); out_uint8(self->out_s, pixel); + out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel >> 16); } else if (Bpp == 2) { @@ -2093,9 +2093,9 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self, if (Bpp == 3) { pixel = GETPIXEL32(data, j, i, width); - out_uint8(self->out_s, pixel >> 16); - out_uint8(self->out_s, pixel >> 8); out_uint8(self->out_s, pixel); + out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel >> 16); } else if (Bpp == 2) { diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index eff2a654..642da9b0 100644 --- a/libxrdp/xrdp_rdp.c +++ b/libxrdp/xrdp_rdp.c @@ -1,7 +1,7 @@ /** * xrdp: A Remote Desktop Protocol server. * - * Copyright (C) Jay Sorg 2004-2012 + * Copyright (C) Jay Sorg 2004-2013 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,17 +114,17 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info) } else { - g_writeln("Warning: Your configured crypt level is" + log_message(LOG_LEVEL_ALWAYS,"Warning: Your configured crypt level is" "undefined 'high' will be used"); client_info->crypt_level = 3; } } - else if (g_strcasecmp(item, "channel_code") == 0) + else if (g_strcasecmp(item, "allow_channels") == 0) { client_info->channel_code = text2bool(value); if (client_info->channel_code == 0) { - g_writeln("Info: All channels are disabled"); + log_message(LOG_LEVEL_DEBUG,"Info - All channels are disabled"); } } else if (g_strcasecmp(item, "max_bpp") == 0) @@ -829,6 +829,7 @@ xrdp_process_capset_order(struct xrdp_rdp *self, struct stream *s, int i; char order_caps[32]; int ex_flags; + int cap_flags; DEBUG(("order capabilities")); in_uint8s(s, 20); /* Terminal desc, pad */ @@ -837,8 +838,9 @@ xrdp_process_capset_order(struct xrdp_rdp *self, struct stream *s, in_uint8s(s, 2); /* Pad */ in_uint8s(s, 2); /* Max order level */ in_uint8s(s, 2); /* Number of fonts */ - in_uint8s(s, 2); /* Capability flags */ + in_uint16_le(s, cap_flags); /* Capability flags */ in_uint8a(s, order_caps, 32); /* Orders supported */ + g_memcpy(self->client_info.orders, order_caps, 32); DEBUG(("dest blt-0 %d", order_caps[0])); DEBUG(("pat blt-1 %d", order_caps[1])); DEBUG(("screen blt-2 %d", order_caps[2])); @@ -862,12 +864,15 @@ xrdp_process_capset_order(struct xrdp_rdp *self, struct stream *s, /* read extended order support flags */ in_uint16_le(s, ex_flags); /* Ex flags */ - if (ex_flags & XR_ORDERFLAGS_EX_CACHE_BITMAP_REV3_SUPPORT) + if (cap_flags & 0x80) /* ORDER_FLAGS_EXTRA_SUPPORT */ { - g_writeln("xrdp_process_capset_order: bitmap cache v3 supported"); - self->client_info.bitmap_cache_version |= 4; + self->client_info.order_flags_ex = ex_flags; + if (ex_flags & XR_ORDERFLAGS_EX_CACHE_BITMAP_REV3_SUPPORT) + { + g_writeln("xrdp_process_capset_order: bitmap cache v3 supported"); + self->client_info.bitmap_cache_version |= 4; + } } - in_uint8s(s, 4); /* Pad */ in_uint32_le(s, i); /* desktop cache size, usually 0x38400 */ @@ -958,11 +963,26 @@ xrdp_process_capset_pointercache(struct xrdp_rdp *self, struct stream *s, int len) { int i; + int colorPointerFlag; - in_uint8s(s, 2); /* color pointer */ + in_uint16_le(s, colorPointerFlag); + self->client_info.pointer_flags = colorPointerFlag; in_uint16_le(s, i); i = MIN(i, 32); self->client_info.pointer_cache_entries = i; + if (colorPointerFlag & 1) + { + g_writeln("xrdp_process_capset_pointercache: client supports " + "new(color) cursor"); + in_uint16_le(s, i); + i = MIN(i, 32); + self->client_info.pointer_cache_entries = i; + } + else + { + g_writeln("xrdp_process_capset_pointercache: client does not support " + "new(color) cursor"); + } return 0; } diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c index 17348274..2cc2d424 100644 --- a/libxrdp/xrdp_sec.c +++ b/libxrdp/xrdp_sec.c @@ -19,6 +19,7 @@ */ #include "libxrdp.h" +#include "log.h" /* some compilers need unsigned char to avoid warnings */ static tui8 g_pad_54[40] = @@ -1056,7 +1057,7 @@ xrdp_sec_incoming(struct xrdp_sec *self) if (file_by_name_read_section(key_file, "keys", items, values) != 0) { /* this is a show stopper */ - g_writeln("xrdp_sec_incoming: error reading %s file", key_file); + log_message(LOG_LEVEL_ALWAYS,"XRDP cannot read file: %s (check permissions)", key_file); list_delete(items); list_delete(values); return 1; |
