libxrdp: work on fastpath input, fix length issue in fastpath_recv

This commit is contained in:
speidy 2014-02-10 06:26:55 +02:00
parent f525c0f8e7
commit f8d26973d0
3 changed files with 15 additions and 6 deletions

View File

@ -82,7 +82,6 @@ struct xrdp_fastpath
struct xrdp_tcp* tcp_layer; struct xrdp_tcp* tcp_layer;
int numEvents; int numEvents;
int secFlags; int secFlags;
int firstPacket;
}; };
/* sec */ /* sec */

View File

@ -56,8 +56,9 @@ int APP_CC
xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s) xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s)
{ {
int fp_hdr; int fp_hdr;
int len; int len = 0;
int byte; int byte;
int hdr_len = 2;
DEBUG((" in xrdp_fastpath_recv")); DEBUG((" in xrdp_fastpath_recv"));
/* read the first fastpath byte /* read the first fastpath byte
@ -67,7 +68,7 @@ xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s)
self->numEvents = (fp_hdr & 0x3C) >> 2; self->numEvents = (fp_hdr & 0x3C) >> 2;
self->secFlags = (fp_hdr & 0xC0) >> 6; self->secFlags = (fp_hdr & 0xC0) >> 6;
// receive fastpath packet length // receive fastpath first packet length
if (xrdp_tcp_recv(self->tcp_layer, s, 1) != 0) if (xrdp_tcp_recv(self->tcp_layer, s, 1) != 0)
{ {
return 1; return 1;
@ -79,6 +80,12 @@ xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s)
{ {
byte &= ~(0x80); byte &= ~(0x80);
len = (byte << 8); len = (byte << 8);
// receive fastpath second packet length
if (xrdp_tcp_recv(self->tcp_layer, s, 1) != 0)
{
return 1;
}
hdr_len++;
in_uint8(s, byte); /* length 2 */ in_uint8(s, byte); /* length 2 */
len += byte; len += byte;
} }
@ -87,8 +94,10 @@ xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s)
len = byte; len = byte;
} }
g_writeln("len= %d , numEvents= %d, secFlags= %d, bytesleft: %d", len, self->numEvents, self->secFlags, (s->p - s->data));
// receive the left bytes // receive the left bytes
if (xrdp_tcp_recv(self->tcp_layer, s, len - (s->p - s->data)) != 0) if (xrdp_tcp_recv(self->tcp_layer, s, len - hdr_len) != 0)
{ {
return 1; return 1;
} }

View File

@ -277,7 +277,6 @@ xrdp_rdp_recv(struct xrdp_rdp *self, struct stream *s, int *code)
if (error == 2) /* we have fastpath packet! */ if (error == 2) /* we have fastpath packet! */
{ {
s->next_packet = 0;
*code = 2; *code = 2;
return 0; return 0;
} }
@ -1710,6 +1709,8 @@ xrdp_rdp_process_fastpath_data_input(struct xrdp_rdp *self, struct stream *s)
int eventFlags; int eventFlags;
int code; int code;
int flags; int flags;
int param2;
int time;
// process fastpath input events // process fastpath input events
for (i = 0 ; i < self->sec_layer->fastpath_layer->numEvents ; i++) { for (i = 0 ; i < self->sec_layer->fastpath_layer->numEvents ; i++) {
@ -1740,7 +1741,7 @@ xrdp_rdp_process_fastpath_data_input(struct xrdp_rdp *self, struct stream *s)
RDP_INPUT_MOUSE - 0x8001 RDP_INPUT_MOUSE - 0x8001
RDP_INPUT_MOUSEX - 0x8002 */ RDP_INPUT_MOUSEX - 0x8002 */
/* call to xrdp_wm.c : callback */ /* call to xrdp_wm.c : callback */
self->session->callback(self->session->id, RDP_INPUT_SCANCODE, flags, 0, self->session->callback(self->session->id, RDP_INPUT_SCANCODE, flags, param2,
code, time); code, time);
} }
break; break;