From 42bda50fe0a9f030ae0ea62a236ed6ae741db3a3 Mon Sep 17 00:00:00 2001 From: norrarvid Date: Fri, 1 Jun 2012 16:20:29 +0200 Subject: Deadlock situation bug fix and improved debug information --- libxrdp/xrdp_mcs.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'libxrdp/xrdp_mcs.c') diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c index af65faf2..57494191 100644 --- a/libxrdp/xrdp_mcs.c +++ b/libxrdp/xrdp_mcs.c @@ -65,11 +65,15 @@ xrdp_mcs_delete(struct xrdp_mcs* self) } list_delete(self->channel_list); xrdp_iso_delete(self->iso_layer); + /* make sure we get null pointer exception if struct is used again. */ + DEBUG(("xrdp_mcs_delete processed")) + g_memset(self,0,sizeof(struct xrdp_mcs)) ; g_free(self); } /*****************************************************************************/ -/* returns error */ +/* This function sends channel join confirm*/ +/* returns error = 1 ok = 0*/ static int APP_CC xrdp_mcs_send_cjcf(struct xrdp_mcs* self, int userid, int chanid) { @@ -87,7 +91,7 @@ xrdp_mcs_send_cjcf(struct xrdp_mcs* self, int userid, int chanid) out_uint8(s, (MCS_CJCF << 2) | 2); out_uint8(s, 0); out_uint16_be(s, userid); - out_uint16_be(s, chanid); + out_uint16_be(s, chanid); /* TODO Explain why we send this two times */ out_uint16_be(s, chanid); s_mark_end(s); if (xrdp_iso_send(self->iso_layer, s) != 0) @@ -122,20 +126,31 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan) } in_uint8(s, opcode); appid = opcode >> 2; - if (appid == MCS_DPUM) + if (appid == MCS_DPUM) /* Disconnect Provider Ultimatum */ { + g_writeln("received Disconnect Provider Ultimatum"); DEBUG((" out xrdp_mcs_recv appid != MCS_DPUM")); return 1; } /* this is channels getting added from the client */ if (appid == MCS_CJRQ) { + g_writeln("channel join request received"); in_uint16_be(s, userid); in_uint16_be(s, chanid); - DEBUG((" adding channel %4.4x", chanid)); - xrdp_mcs_send_cjcf(self, userid, chanid); + 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") ; + } continue; } + if(appid==MCS_SDRQ || appid==MCS_SDIN) + { + break ; + }else{ + g_writeln("Recieved an unhandled appid:%d",appid); + } break; } if (appid != MCS_SDRQ) -- cgit v1.2.3 From 67a2a3c4c7c2487dffd487a93d7bfe3e89f2328f Mon Sep 17 00:00:00 2001 From: norrarvid Date: Mon, 18 Jun 2012 08:48:51 +0200 Subject: layout fix --- libxrdp/xrdp_channel.c | 2 +- libxrdp/xrdp_mcs.c | 6 ++++-- libxrdp/xrdp_rdp.c | 8 ++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'libxrdp/xrdp_mcs.c') diff --git a/libxrdp/xrdp_channel.c b/libxrdp/xrdp_channel.c index 4085f650..092cefa4 100644 --- a/libxrdp/xrdp_channel.c +++ b/libxrdp/xrdp_channel.c @@ -66,7 +66,7 @@ xrdp_channel_delete(struct xrdp_channel* self) { return; } - memset(self,0,sizeof(struct xrdp_channel)); + g_memset(self,0,sizeof(struct xrdp_channel)); g_free(self); } diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c index 57494191..1a7a0411 100644 --- a/libxrdp/xrdp_mcs.c +++ b/libxrdp/xrdp_mcs.c @@ -141,14 +141,16 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan) 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") ; + g_writeln("Non handled error from xrdp_mcs_send_cjcf") ; } continue; } if(appid==MCS_SDRQ || appid==MCS_SDIN) { break ; - }else{ + } + else + { g_writeln("Recieved an unhandled appid:%d",appid); } break; diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index 54f8a24f..497b9c7d 100644 --- a/libxrdp/xrdp_rdp.c +++ b/libxrdp/xrdp_rdp.c @@ -251,7 +251,9 @@ xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code) { g_writeln("xrdp_channel_process returned unhandled error") ; } - }else{ + } + else + { g_writeln("Wrong channel Id to be handled by xrdp_channel_process %d",chan); } s->next_packet = 0; @@ -274,7 +276,9 @@ xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code) len = (int)(s->end - s->p); g_writeln("xrdp_rdp_recv: bad RDP packet, length [%d]", len); return 0; - }else{ + } + else + { in_uint16_le(s, len); /*g_writeln("New len received : %d next packet: %d s_end: %d",len,s->next_packet,s->end); */ in_uint16_le(s, pdu_code); -- cgit v1.2.3