summaryrefslogtreecommitdiffstats
path: root/sesman
diff options
context:
space:
mode:
authorilsimo <ilsimo>2007-03-24 16:30:43 +0000
committerilsimo <ilsimo>2007-03-24 16:30:43 +0000
commit831ef476b76959ed185fefeea552d01b51765771 (patch)
tree7254f8df85ef9e31cb7452d3daa2065d6b0cacd5 /sesman
parentae9faad218563b46c0a4a00fc584454dbd566825 (diff)
downloadxrdp-proprietary-831ef476b76959ed185fefeea552d01b51765771.tar.gz
xrdp-proprietary-831ef476b76959ed185fefeea552d01b51765771.zip
some fixes for scp v0
Diffstat (limited to 'sesman')
-rw-r--r--sesman/libscp_v0.c67
-rw-r--r--sesman/libscp_v0.h8
2 files changed, 63 insertions, 12 deletions
diff --git a/sesman/libscp_v0.c b/sesman/libscp_v0.c
index f6587c42..34675874 100644
--- a/sesman/libscp_v0.c
+++ b/sesman/libscp_v0.c
@@ -30,10 +30,12 @@
#include "os_calls.h"
/* client API */
/******************************************************************************/
-enum SCP_CLIENT_STATES_E scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s, SCP_DISPLAY* d)
+enum SCP_CLIENT_STATES_E scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
{
+ uint32_t version;
+ uint32_t size;
uint16_t sz;
-
+
init_stream(c->in_s, c->in_s->size);
init_stream(c->out_s, c->in_s->size);
@@ -41,7 +43,18 @@ enum SCP_CLIENT_STATES_E scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SE
g_tcp_set_no_delay(c->in_sck);
s_push_layer(c->out_s, channel_hdr, 8);
- out_uint16_be(c->out_s, 10); // code
+ if (s->type==SCP_SESSION_TYPE_XVNC)
+ {
+ out_uint16_be(c->out_s, 0); // code
+ }
+ else if (s->type==SCP_SESSION_TYPE_XRDP)
+ {
+ out_uint16_be(c->out_s, 10); // code
+ }
+ else
+ {
+ return SCP_CLIENT_STATE_INTERNAL_ERR;
+ }
sz = g_strlen(s->username);
out_uint16_be(c->out_s, sz);
out_uint8a(c->out_s, s->username, sz);
@@ -64,7 +77,45 @@ enum SCP_CLIENT_STATES_E scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SE
return SCP_CLIENT_STATE_NETWORK_ERR;
}
- return SCP_CLIENT_STATE_OK;
+ if (0!=tcp_force_recv(c->in_sck, c->in_s->data, 8))
+ {
+ return SCP_CLIENT_STATE_NETWORK_ERR;
+ }
+
+ in_uint32_be(c->in_s, version);
+ if (0 != version)
+ {
+ return SCP_CLIENT_STATE_VERSION_ERR;
+ }
+
+ in_uint32_be(c->in_s, size);
+ if (size < 14)
+ {
+ return SCP_CLIENT_STATE_SIZE_ERR;
+ }
+
+ init_stream(c->in_s, c->in_s->size);
+ if (0!=tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
+ {
+ return SCP_CLIENT_STATE_NETWORK_ERR;
+ }
+
+ in_uint16_be(c->in_s, sz);
+ if (3!=sz)
+ {
+ return SCP_CLIENT_STATE_SEQUENCE_ERR;
+ }
+
+ in_uint16_be(c->in_s, sz);
+ if (1!=sz)
+ {
+ return SCP_CLIENT_STATE_CONNECTION_DENIED;
+ }
+
+ in_uint16_be(c->in_s, sz);
+ s->display=sz;
+
+ return SCP_CLIENT_STATE_END;
}
/* server API */
@@ -103,16 +154,16 @@ enum SCP_SERVER_STATES_E scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SES
in_uint16_be(c->in_s, code);
- if (code == 0 || code == 10)
+ if (code == 0 || code == 10)
{
session = g_malloc(sizeof(struct SCP_SESSION),1);
if (0 == session)
{
return SCP_SERVER_STATE_INTERNAL_ERR;
}
-
+
session->version=version;
-
+
if (code == 0)
{
session->type=SCP_SESSION_TYPE_XVNC;
@@ -121,7 +172,7 @@ enum SCP_SERVER_STATES_E scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SES
{
session->type=SCP_SESSION_TYPE_XRDP;
}
-
+
/* reading username */
in_uint16_be(c->in_s, sz);
session->username=g_malloc(sz+1,0);
diff --git a/sesman/libscp_v0.h b/sesman/libscp_v0.h
index 0071e227..1bad9e60 100644
--- a/sesman/libscp_v0.h
+++ b/sesman/libscp_v0.h
@@ -18,11 +18,11 @@
*/
/**
- *
+ *
* @file libscp_v0.h
* @brief libscp version 0 declarations
* @author Simone Fedele
- *
+ *
*/
#ifndef LIBSCP_V0_H
@@ -39,7 +39,7 @@
* @param d display
*
*/
-enum SCP_CLIENT_STATES_E scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s, SCP_DISPLAY* d);
+enum SCP_CLIENT_STATES_E scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
/* server API */
/**
@@ -47,7 +47,7 @@ enum SCP_CLIENT_STATES_E scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SE
* @brief processes the stream using scp version 0
* @param c connection descriptor
* @param s session descriptor
- * @param skipVchk if set to !0 skips the version control (to be used after
+ * @param skipVchk if set to !0 skips the version control (to be used after
* scp_vXs_accept() )
*
*/