--- sourceforge.net/trunk/rdesktop/channels.c 2003/07/09 09:18:20 435 +++ sourceforge.net/trunk/rdesktop/channels.c 2003/08/18 04:52:51 446 @@ -27,14 +27,14 @@ #define CHANNEL_FLAG_LAST 0x02 #define CHANNEL_FLAG_SHOW_PROTOCOL 0x10 -extern BOOL use_rdp5; -extern BOOL encryption; +extern BOOL g_use_rdp5; +extern BOOL g_encryption; VCHANNEL g_channels[MAX_CHANNELS]; unsigned int g_num_channels; /* FIXME: We should use the information in TAG_SRV_CHANNELS to map RDP5 - channels to MCS channels. + channels to MCS channels. The format of TAG_SRV_CHANNELS seems to be @@ -48,7 +48,7 @@ { VCHANNEL *channel; - if (!use_rdp5) + if (!g_use_rdp5) return NULL; if (g_num_channels >= MAX_CHANNELS) @@ -71,7 +71,7 @@ { STREAM s; - s = sec_init(encryption ? SEC_ENCRYPT : 0, length + 8); + s = sec_init(g_encryption ? SEC_ENCRYPT : 0, length + 8); s_push_layer(s, channel_hdr, 8); return s; } @@ -96,7 +96,7 @@ out_uint32_le(s, length); out_uint32_le(s, flags); data = s->end = s->p + thislength; - sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, channel->mcs_id); + sec_send_to_channel(s, g_encryption ? SEC_ENCRYPT : 0, channel->mcs_id); /* subsequent segments copied (otherwise would have to generate headers backwards) */ while (remaining > 0) @@ -105,12 +105,12 @@ remaining -= thislength; flags = (remaining == 0) ? CHANNEL_FLAG_LAST : 0; - s = sec_init(encryption ? SEC_ENCRYPT : 0, thislength + 8); + s = sec_init(g_encryption ? SEC_ENCRYPT : 0, thislength + 8); out_uint32_le(s, length); out_uint32_le(s, flags); out_uint8p(s, data, thislength); s_mark_end(s); - sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, channel->mcs_id); + sec_send_to_channel(s, g_encryption ? SEC_ENCRYPT : 0, channel->mcs_id); data += thislength; } @@ -156,13 +156,13 @@ in->p = in->data; } - thislength = s->end - s->p; + thislength = MIN(s->end - s->p, in->data + in->size - in->p); memcpy(in->p, s->p, thislength); - s->p += thislength; - s->end += thislength; + in->p += thislength; if (flags & CHANNEL_FLAG_LAST) { + in->end = in->p; in->p = in->data; channel->process(in); }