diff options
author | speidy <speidy@gmail.com> | 2014-03-05 06:06:50 +0200 |
---|---|---|
committer | speidy <speidy@gmail.com> | 2014-03-05 06:06:50 +0200 |
commit | 44d831f05ec044b1feaf714e53ff233c1fbc1ba7 (patch) | |
tree | 687b3b617067d0d7d62a914a16d785e84d53eb86 /libxrdp/xrdp_fastpath.c | |
parent | d6101015215bc157801c79be6c3684677f627b47 (diff) | |
download | xrdp-proprietary-44d831f05ec044b1feaf714e53ff233c1fbc1ba7.tar.gz xrdp-proprietary-44d831f05ec044b1feaf714e53ff233c1fbc1ba7.zip |
libxrdp: fastpath, add stream check (all stack)
Diffstat (limited to 'libxrdp/xrdp_fastpath.c')
-rw-r--r-- | libxrdp/xrdp_fastpath.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/libxrdp/xrdp_fastpath.c b/libxrdp/xrdp_fastpath.c index 2fa88ac6..d031f003 100644 --- a/libxrdp/xrdp_fastpath.c +++ b/libxrdp/xrdp_fastpath.c @@ -57,24 +57,37 @@ int APP_CC xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s) { int fp_hdr; - int len = 0; + int len = 0; /* unused */ int byte; DEBUG((" in xrdp_fastpath_recv")); + if (!s_check_rem(s, 2)) + { + return 1; + } in_uint8(s, fp_hdr); /* fpInputHeader (1 byte) */ + in_uint8(s, byte); /* length 1 (1 byte) */ self->numEvents = (fp_hdr & 0x3C) >> 2; self->secFlags = (fp_hdr & 0xC0) >> 6; - in_uint8(s, byte); /* length 1 (1 byte) */ - if (byte & 0x80) { byte &= ~(0x80); len = (byte << 8); + + if (!s_check_rem(s, 1)) + { + return 1; + } in_uint8(s, byte); /* length 2 (1 byte) */ + len += byte; } + else + { + len = byte; + } DEBUG((" out xrdp_fastpath_recv")); @@ -243,8 +256,11 @@ xrdp_fastpath_process_EVENT_SCANCODE(struct xrdp_fastpath *self, int eventFlags, int code; flags = 0; + if (!s_check_rem(s, 1)) + { + return 1; + } in_uint8(s, code); /* keyCode (1 byte) */ - //g_writeln("scan code detected: %d", code); if ((eventFlags & FASTPATH_INPUT_KBDFLAGS_RELEASE)) flags |= KBD_FLAG_UP; @@ -276,6 +292,10 @@ xrdp_fastpath_process_EVENT_MOUSE(struct xrdp_fastpath *self, int eventFlags, st int xPos; int yPos; + if (!s_check_rem(s, 2 + 2 + 2)) + { + return 1; + } in_uint16_le(s, pointerFlags); /* pointerFlags (2 bytes) */ in_uint16_le(s, xPos); /* xPos (2 bytes) */ in_uint16_le(s, yPos); /* yPos (2 bytes) */ @@ -302,6 +322,10 @@ xrdp_fastpath_process_EVENT_MOUSEX(struct xrdp_fastpath *self, int eventFlags, s int xPos; int yPos; + if (!s_check_rem(s, 2 + 2 + 2)) + { + return 1; + } in_uint16_le(s, pointerFlags); /* pointerFlags (2 bytes) */ in_uint16_le(s, xPos); /* xPos (2 bytes) */ in_uint16_le(s, yPos); /* yPos (2 bytes) */ @@ -347,6 +371,10 @@ xrdp_fastpath_process_EVENT_SYNC(struct xrdp_fastpath *self, int eventCode, int int APP_CC xrdp_fastpath_process_EVENT_UNICODE(struct xrdp_fastpath *self, int eventFlags, struct stream *s) { + if (!s_check_rem(s, 2)) + { + return 1; + } in_uint8s(s, 2); return 0; } @@ -362,13 +390,17 @@ xrdp_fastpath_process_input_event(struct xrdp_fastpath *self, struct stream *s) // process fastpath input events for (i = 0 ; i < self->numEvents ; i++) { + if (!s_check_rem(s, 1)) + { + return 1; + } in_uint8(s, eventHeader); eventFlags = (eventHeader & 0x1F); eventCode = (eventHeader >> 5); -// g_writeln("eventCode= %d, eventFlags= %d, numEvents= %d", -// eventCode, eventFlags, self->sec_layer->fastpath_layer->numEvents); + //DEBUG(("xrdp_fastpath_process_input_event: eventCode= %d, eventFlags= %d, numEvents= %d", + // eventCode, eventFlags, self->sec_layer->fastpath_layer->numEvents)); switch (eventCode) { @@ -402,10 +434,9 @@ xrdp_fastpath_process_input_event(struct xrdp_fastpath *self, struct stream *s) { return 1; } - break; default: - g_writeln("xrdp_rdp_process_fastpath_data_input: unknown eventCode %d", eventCode); + g_writeln("xrdp_fastpath_process_input_event: unknown eventCode %d", eventCode); break; } |