Eliminate previous ugly hack for RDP5 packets, in order to make it work

with low encryption.


git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@422 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
Matt Chapman 2003-06-17 08:44:32 +00:00
parent c864378465
commit 2c32c1ec3a
4 changed files with 36 additions and 23 deletions

12
iso.c
View File

@ -77,10 +77,9 @@ iso_recv_msg(uint8 * code)
STREAM s;
uint16 length;
uint8 version;
BOOL shortform = False; // Shut the compiler up.
next_packet:
s = tcp_recv(4);
s = tcp_recv(NULL, 4);
if (s == NULL)
return NULL;
@ -93,11 +92,6 @@ iso_recv_msg(uint8 * code)
{
length &= ~0x80;
next_be(s, length);
shortform = False;
}
else
{
shortform = True;
}
break;
@ -111,13 +105,13 @@ iso_recv_msg(uint8 * code)
return NULL;
}
s = tcp_recv(length - 4);
s = tcp_recv(s, length - 4);
if (s == NULL)
return NULL;
if ((version & 3) == 0)
{
rdp5_process(s, version & 0x80, shortform);
rdp5_process(s, version & 0x80);
goto next_packet;
}

View File

@ -80,7 +80,7 @@ BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password, char
char *directory);
void rdp_disconnect(void);
/* rdp5.c */
void rdp5_process(STREAM s, BOOL encryption, BOOL shortform);
void rdp5_process(STREAM s, BOOL encryption);
void rdp5_process_channel(STREAM s, uint16 channelno);
/* secure.c */
void sec_hash_48(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2, uint8 salt);
@ -99,7 +99,7 @@ void sec_disconnect(void);
/* tcp.c */
STREAM tcp_init(uint32 maxlen);
void tcp_send(STREAM s);
STREAM tcp_recv(uint32 length);
STREAM tcp_recv(STREAM s, uint32 length);
BOOL tcp_connect(char *server);
void tcp_disconnect(void);
/* xkeymap.c */

4
rdp5.c
View File

@ -24,7 +24,7 @@
extern uint8 *next_packet;
void
rdp5_process(STREAM s, BOOL encryption, BOOL shortform)
rdp5_process(STREAM s, BOOL encryption)
{
uint16 length, count;
uint8 type;
@ -32,7 +32,7 @@ rdp5_process(STREAM s, BOOL encryption, BOOL shortform)
if (encryption)
{
in_uint8s(s, shortform ? 6 : 7 /* XXX HACK */ ); /* signature */
in_uint8s(s, 8); /* signature */
sec_decrypt(s->p, s->end - s->p);
}

39
tcp.c
View File

@ -74,17 +74,36 @@ tcp_send(STREAM s)
/* Receive a message on the TCP layer */
STREAM
tcp_recv(uint32 length)
tcp_recv(STREAM s, uint32 length)
{
unsigned int new_length, end_offset, p_offset;
int rcvd = 0;
if (length > in.size)
if (s == NULL)
{
in.data = (uint8 *) xrealloc(in.data, length);
in.size = length;
/* read into "new" stream */
if (length > in.size)
{
in.data = (uint8 *) xrealloc(in.data, length);
in.size = length;
}
in.end = in.p = in.data;
s = ∈
}
else
{
/* append to existing stream */
new_length = (s->end - s->data) + length;
if (new_length > s->size)
{
p_offset = s->p - s->data;
end_offset = s->end - s->data;
s->data = (uint8 *) xrealloc(s->data, new_length);
s->size = new_length;
s->p = s->data + p_offset;
s->end = s->data + end_offset;
}
}
in.end = in.p = in.data;
while (length > 0)
{
@ -92,18 +111,18 @@ tcp_recv(uint32 length)
/* User quit */
return NULL;
rcvd = recv(sock, in.end, length, 0);
if (rcvd == -1)
rcvd = recv(sock, s->end, length, 0);
if (rcvd <= 0)
{
error("recv: %s\n", strerror(errno));
return NULL;
}
in.end += rcvd;
s->end += rcvd;
length -= rcvd;
}
return &in;
return s;
}
/* Establish a connection on the TCP layer */