The fastpath header can be two or three bytes long. Check also the latter case.

This commit is contained in:
Pawel Jakub Dawidek 2012-02-08 11:50:29 +01:00
parent 58e08a7726
commit e9f89af8a5
3 changed files with 24 additions and 0 deletions

View File

@ -49,6 +49,22 @@
* @return length
*/
/*
* The fastpath header may be two or three bytes long.
* This function assumes that at least two bytes are available in the stream
* and doesn't touch third byte.
*/
uint16 fastpath_header_length(STREAM* s)
{
uint8 length1;
stream_seek_uint8(s);
stream_read_uint8(s, length1);
stream_rewind(s, 2);
return ((length1 & 0x80) != 0 ? 3 : 2);
}
uint16 fastpath_read_header(rdpFastPath* fastpath, STREAM* s)
{
uint8 header;

View File

@ -102,6 +102,7 @@ struct rdp_fastpath
STREAM* updateData;
};
uint16 fastpath_header_length(STREAM* s);
uint16 fastpath_read_header(rdpFastPath* fastpath, STREAM* s);
uint16 fastpath_read_header_rdp(rdpFastPath* fastpath, STREAM* s);
boolean fastpath_recv_updates(rdpFastPath* fastpath, STREAM* s);

View File

@ -312,6 +312,13 @@ int transport_check_fds(rdpTransport* transport)
stream_set_pos(transport->recv_buffer, pos);
return 0;
}
/* Fastpath header can be two or three bytes long. */
length = fastpath_header_length(transport->recv_buffer);
if (pos < length)
{
stream_set_pos(transport->recv_buffer, pos);
return 0;
}
length = fastpath_read_header(NULL, transport->recv_buffer);
}