1 |
/* -*- c-basic-offset: 8 -*- |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
Protocol services - RDP layer |
Protocol services - RDP layer |
4 |
Copyright (C) Matthew Chapman 1999-2007 |
Copyright (C) Matthew Chapman 1999-2008 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
36 |
#endif |
#endif |
37 |
|
|
38 |
extern uint16 g_mcs_userid; |
extern uint16 g_mcs_userid; |
39 |
extern char g_username[64]; |
extern char *g_username; |
40 |
extern char g_codepage[16]; |
extern char g_codepage[16]; |
41 |
extern RD_BOOL g_bitmap_compression; |
extern RD_BOOL g_bitmap_compression; |
42 |
extern RD_BOOL g_orders; |
extern RD_BOOL g_orders; |
63 |
extern char g_redirect_server[64]; |
extern char g_redirect_server[64]; |
64 |
extern char g_redirect_domain[16]; |
extern char g_redirect_domain[16]; |
65 |
extern char g_redirect_password[64]; |
extern char g_redirect_password[64]; |
66 |
extern char g_redirect_username[64]; |
extern char *g_redirect_username; |
67 |
extern char g_redirect_cookie[128]; |
extern char g_redirect_cookie[128]; |
68 |
extern uint32 g_redirect_flags; |
extern uint32 g_redirect_flags; |
69 |
/* END Session Directory support */ |
/* END Session Directory support */ |
246 |
rdp_in_unistr(STREAM s, char *string, int str_size, int in_len) |
rdp_in_unistr(STREAM s, char *string, int str_size, int in_len) |
247 |
{ |
{ |
248 |
#ifdef HAVE_ICONV |
#ifdef HAVE_ICONV |
249 |
size_t ibl = in_len, obl = str_size-1; |
size_t ibl = in_len, obl = str_size - 1; |
250 |
char *pin = (char *) s->p, *pout = string; |
char *pin = (char *) s->p, *pout = string; |
251 |
static iconv_t iconv_h = (iconv_t) - 1; |
static iconv_t iconv_h = (iconv_t) - 1; |
252 |
|
|
291 |
#endif |
#endif |
292 |
{ |
{ |
293 |
int i = 0; |
int i = 0; |
294 |
int len = in_len/2; |
int len = in_len / 2; |
295 |
int rem = 0; |
int rem = 0; |
296 |
|
|
297 |
if (len > str_size-1) |
if (len > str_size - 1) |
298 |
{ |
{ |
299 |
warning("server sent an unexpectedly long string, truncating\n"); |
warning("server sent an unexpectedly long string, truncating\n"); |
300 |
len = str_size-1; |
len = str_size - 1; |
301 |
rem = in_len - 2*len; |
rem = in_len - 2 * len; |
302 |
} |
} |
303 |
|
|
304 |
while (i < len) |
while (i < len) |
800 |
out_uint16(s, 0); /* pad */ |
out_uint16(s, 0); /* pad */ |
801 |
} |
} |
802 |
|
|
803 |
|
/* Output brush cache capability set */ |
804 |
|
static void |
805 |
|
rdp_out_brushcache_caps(STREAM s) |
806 |
|
{ |
807 |
|
out_uint16_le(s, RDP_CAPSET_BRUSHCACHE); |
808 |
|
out_uint16_le(s, RDP_CAPLEN_BRUSHCACHE); |
809 |
|
out_uint32_le(s, 1); /* cache type */ |
810 |
|
} |
811 |
|
|
812 |
static uint8 caps_0x0d[] = { |
static uint8 caps_0x0d[] = { |
813 |
0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, |
0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, |
814 |
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
858 |
RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE + |
RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE + |
859 |
RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL + |
RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL + |
860 |
RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE + |
RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE + |
861 |
0x58 + 0x08 + 0x08 + 0x34 /* unknown caps */ + |
RDP_CAPLEN_BRUSHCACHE + 0x58 + 0x08 + 0x08 + 0x34 /* unknown caps */ + |
862 |
4 /* w2k fix, why? */ ; |
4 /* w2k fix, why? */ ; |
863 |
|
|
864 |
s = sec_init(sec_flags, 6 + 14 + caplen + sizeof(RDP_SOURCE)); |
s = sec_init(sec_flags, 6 + 14 + caplen + sizeof(RDP_SOURCE)); |
885 |
rdp_out_control_caps(s); |
rdp_out_control_caps(s); |
886 |
rdp_out_pointer_caps(s); |
rdp_out_pointer_caps(s); |
887 |
rdp_out_share_caps(s); |
rdp_out_share_caps(s); |
888 |
|
rdp_out_brushcache_caps(s); |
889 |
|
|
890 |
rdp_out_unknown_caps(s, 0x0d, 0x58, caps_0x0d); /* international? */ |
rdp_out_unknown_caps(s, 0x0d, 0x58, caps_0x0d); /* international? */ |
891 |
rdp_out_unknown_caps(s, 0x0c, 0x08, caps_0x0c); |
rdp_out_unknown_caps(s, 0x0c, 0x08, caps_0x0c); |
1360 |
in_uint32_le(s, len); |
in_uint32_le(s, len); |
1361 |
|
|
1362 |
/* read cookie string (plain ASCII) */ |
/* read cookie string (plain ASCII) */ |
1363 |
if (len > sizeof(g_redirect_cookie)-1) |
if (len > sizeof(g_redirect_cookie) - 1) |
1364 |
{ |
{ |
1365 |
uint32 rem = len - (sizeof(g_redirect_cookie)-1); |
uint32 rem = len - (sizeof(g_redirect_cookie) - 1); |
1366 |
len = sizeof(g_redirect_cookie)-1; |
len = sizeof(g_redirect_cookie) - 1; |
1367 |
|
|
1368 |
warning("Unexpectedly large redirection cookie\n"); |
warning("Unexpectedly large redirection cookie\n"); |
1369 |
in_uint8a(s, g_redirect_cookie, len); |
in_uint8a(s, g_redirect_cookie, len); |
1379 |
in_uint32_le(s, len); |
in_uint32_le(s, len); |
1380 |
|
|
1381 |
/* read username string */ |
/* read username string */ |
1382 |
rdp_in_unistr(s, g_redirect_username, sizeof(g_redirect_username), len); |
g_redirect_username = (char *) xmalloc(len + 1); |
1383 |
|
rdp_in_unistr(s, g_redirect_username, strlen(g_redirect_username), len); |
1384 |
|
|
1385 |
/* read length of domain string */ |
/* read length of domain string */ |
1386 |
in_uint32_le(s, len); |
in_uint32_le(s, len); |