Commit Graph

212 Commits

Author SHA1 Message Date
Pierre Ossman
a646a5cce2 Be tolerant of cropped TS_SHARECONTROLHEADER
Old versions of Windows (e.g. XP) sends a cropped packet in some
cases. It still contains all the important parts, so let's be
tolerant of this misbehaviour.
2019-09-19 09:18:42 +02:00
Pierre Ossman
77758c3c18 Handle empty unicode strings from server 2019-05-06 14:33:38 +02:00
Pierre Ossman
25b8412333 Avoid poking around in STREAM internals
It's easy to make mistakes this way, and bypassed the normal bounds
checking. So make sure we always use macros or functions.
2019-05-06 14:33:38 +02:00
Pierre Ossman
c6d8b933c8 Avoid preallocated streams in tcp.c
We don't know when the caller might be done with a stream, so we
can end up with code overwriting things in a stream that is in use
elsewhere.

Solve the issue by returning a new stream each time and leave it
up to the callers to free it.
2019-05-06 14:33:05 +02:00
Pierre Ossman
75221eb3c5 Separate behaviour of out_uint8a and out_uint8p
Make them more match in_uint8a and in_uint8p in that one copies and
the other just gives you a pointer and it is up to the caller how
to fill it in. This can be useful when other APIs are used to
generate the data as it avoids a temporary buffer.
2019-05-06 14:33:05 +02:00
Pierre Ossman
6268b44f06 Add macro to check remaining length of STREAM
Avoids poking around in the internals, and also makes the code
easier to read.
2019-05-06 14:33:05 +02:00
Pierre Ossman
e099d79879 Remove dangerous s_check()
This macro checks if a pointer is valid _after_ we've already used
that pointer. So it will only trigger if we're already performed some
for of buffer overflow. As such, it provides little to no value and
can only server to encourage broken behaviour.

Let's remove it and replace it with proper bounds checking before
access instead.
2019-05-06 14:33:05 +02:00
Pierre Ossman
e1537061bf Fix packet debug output in rdp_protocol_error()
We're trying to print the entire packet, not just what's left.
2019-05-06 13:30:13 +02:00
Pierre Ossman
d8b0f3782a Give source code info in rdp_protocol_error()
Makes it easier to debug things by seeing exactly where the protocol
handling crashed.
2019-05-06 13:29:44 +02:00
Pierre Ossman
df94870c91 Remove unused variables and functions 2019-04-12 14:37:24 +02:00
Alexander Zakharov
85f99edd65 Update copyrights 2019-02-01 11:21:32 +03:00
Pierre Ossman
17363d9e4d Get a private copy of the redirect cookie
We accidentally just changed the pointer rather than copying the
cookie in to our freshly allocated buffer. This caused problems
after 74b2129e as we started freeing the stream buffers on
disconnect.
2019-01-30 11:00:23 +01:00
Alexander Zakharov
774a657975 Handle insufficient server side buffer for smartcard operations
We should pay attention to OutputBufferLength of DR_CONTROL_REQ
and send STATUS_BUFFER_TOO_SMALL if it's insufficient for returned
result.
2019-01-23 16:12:21 +03:00
Henrik Andersson
4dca546d04 Malicious RDP server security fixes
This commit includes fixes for a set of 21 vulnerabilities in
rdesktop when a malicious RDP server is used.

All vulnerabilities was identified and reported by Eyal Itkin.

 * Add rdp_protocol_error function that is used in several fixes
 * Refactor of process_bitmap_updates
 * Fix possible integer overflow in s_check_rem() on 32bit arch
 * Fix memory corruption in process_bitmap_data - CVE-2018-8794
 * Fix remote code execution in process_bitmap_data - CVE-2018-8795
 * Fix remote code execution in process_plane - CVE-2018-8797
 * Fix Denial of Service in mcs_recv_connect_response - CVE-2018-20175
 * Fix Denial of Service in mcs_parse_domain_params - CVE-2018-20175
 * Fix Denial of Service in sec_parse_crypt_info - CVE-2018-20176
 * Fix Denial of Service in sec_recv - CVE-2018-20176
 * Fix minor information leak in rdpdr_process - CVE-2018-8791
 * Fix Denial of Service in cssp_read_tsrequest - CVE-2018-8792
 * Fix remote code execution in cssp_read_tsrequest - CVE-2018-8793
 * Fix Denial of Service in process_bitmap_data - CVE-2018-8796
 * Fix minor information leak in rdpsnd_process_ping - CVE-2018-8798
 * Fix Denial of Service in process_secondary_order - CVE-2018-8799
 * Fix remote code execution in in ui_clip_handle_data - CVE-2018-8800
 * Fix major information leak in ui_clip_handle_data - CVE-2018-20174
 * Fix memory corruption in rdp_in_unistr - CVE-2018-20177
 * Fix Denial of Service in process_demand_active - CVE-2018-20178
 * Fix remote code execution in lspci_process - CVE-2018-20179
 * Fix remote code execution in rdpsnddbg_process - CVE-2018-20180
 * Fix remote code execution in seamless_process - CVE-2018-20181
 * Fix remote code execution in seamless_process_line - CVE-2018-20182
2019-01-16 12:28:44 +01:00
Henrik Andersson
c16b74a974 Run indent-all.sh script on source 2018-10-29 15:53:57 +01:00
Henrik Andersson
567b1f7432 Clear password is smart card pin upon redirect
Upon a redirection, we have received a cookie that is used
for authentication and we should not flag this as a pin
code for the smartcard. This solves a problem with incorrect
pin code when using smart card authentication and if
redirected to a server were a session exists.
2018-04-17 16:57:05 +02:00
Cendio
8bc2cea80f Add check if we can use dynamic session resize
When the server does not comply with our initial session size
request, we disable the dynamic session resize feature.

Co-authored-by: Henrik Andersson <hean01@cendio.com>
Co-authored-by: Karl Mikaelsson <derfian@cendio.se>
2018-02-14 10:49:30 +01:00
Cendio
9d163423eb Fullscreen windows should not be resized to match the session size
Given that a fullscreen window should have the same size as the
screen, when the server tells us a session size, then we can't
resize the fullscreen window.

Co-authored-by: Henrik Andersson <hean01@cendio.com>
Co-authored-by: Karl Mikaelsson <derfian@cendio.se>
2018-02-13 14:14:02 +01:00
Henrik Andersson
1a82d4139b Cleanup of rdp_loop() and rdp_recv() for clarity 2018-02-01 13:12:57 +01:00
Henrik Andersson
b5708cf775 Refactoring of slow and fastpath handling
This changes clarifies a chunk of code related to receiving
data and handle slow and fast path pdus.
2018-02-01 12:47:22 +01:00
Cendio
58d8f78eea Add lots of protocol debug logging
Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Karl Mikaelsson <derfian@cendio.se>
2018-01-31 11:03:32 +01:00
Cendio
07abc9bade Defer pending resize until after autoreconnect cookie is received
Resize session using disconnect/reconnect sequence should not be
performed before we have received an auto-reconnect cookie which is
used for reconnecting to the session. There is a race when trying to
reconnect at this point so a defer timer is used to delay this further
from the point where the auto-reconnect cookie is received.

Fixes a problem where a login prompt is shown upon reconnect even if
the auto-reconnect cookie is available and used.

Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Karl Mikaelsson <derfian@cendio.se>
2018-01-31 11:03:32 +01:00
Cendio
293680c034 Use hex constants for data pdu (pdutype2) enumeration
This matches how they're described in MS-RDPBCGR. Also add the proper
constant name as comments.

Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Thomas Nilefalk <thoni56@cendio.se>
2018-01-31 11:03:32 +01:00
Cendio
2491a3c436 Clear g_exit_mainloop before new connection
Reuse of g_exit_mainloop can occur at various situations
such as on redirection, when a new connection is initialized.

If you call rdp_loop with this flag set, things will not work as
you'd expect.

Fixes issue #228

Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Karl Mikaelsson <derfian@cendio.se>
2018-01-29 14:05:16 +01:00
Karl Mikaelsson
2f6cd4df7e Improve handling/code of Set Error Info PDU
Renamed to function to match the PDU it was processing. Removed the
function from proto.h and made it static - there's nothing calling
this from outside of rdp.c. Fixed the logging output to output the
error code instead of the pointer value.
2018-01-25 16:47:17 +01:00
Karl Mikaelsson
ca5c0adefd Rename rdp_send_logon_info to rdp_send_client_info_pdu 2018-01-25 16:47:17 +01:00
Cendio
7f76e2218a Rename of global variable for clarity
Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Thomas Nilefalk <thoni56@cendio.se>
2018-01-11 15:10:05 +01:00
Cendio
ab50ea31cf Implement dynamic session resize
This adds support for resizing the RDP session dynamically based on
the window size. Some complicated logic has been added to avoid
sending excessive amounts of resize requests to the RDP server.

When supported, this resize mechanism should use the RDPEDISP way of
signalling the server to initiate a Deactivate/Activate sequence, but
rdesktop will fall back on Disconnect/Reconnect if RDPEDISP is not
supported by the server.

ui_select has been refactored and most functionality has been broken
out into three new functions, simplifying ui_select into a loop.

Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Karl Mikaelsson <derfian@cendio.se>
Signed-off-by: Thomas Nilefalk <thoni56@cendio.se>
2017-12-07 11:15:03 +01:00
Cendio
d037db1086 Increase default desktop size and enable wallpaper 2017-11-09 17:15:16 +01:00
Henrik Andersson
d3d6613c78 Fix compiler warning 2017-11-03 12:49:11 +01:00
René Genz
9e99dd52d6 Fix minor spelling mistakes 2017-11-02 01:01:44 +01:00
Joshua Hudson
e7cda3dbf8 add -M for local mouse cursor 2017-11-01 06:47:31 +01:00
Henrik Andersson
5aa5a9dbfc Minor refactor of process_logon_pdu() 2017-11-01 06:47:31 +01:00
Karl Mikaelsson
8f83c1f6c7 Rename suppress output functions to match MS-RDPBCGR
Issue #161
2017-10-30 10:47:21 +01:00
Karl Mikaelsson
99f5925cce Enable support for large pointers
The cursor-handling code already handles larger pointer sizes. This
advertises that rdesktop has the capability to handle large cursors
and adjusts the maximum size of fragmented packets to suit the large
cursor requirements.

Solves issue #173.
2017-10-16 19:26:30 +02:00
Henrik Andersson
032d67f6ac Remove global variable g_bitmap_compression
g_bitmap_compression is a global variable scattered through the code
but only accessed and used in one place; rdp_out_bitmap_caps().
Demoted it to localvariable and replaced with hardcoded value.
2017-10-16 15:34:47 +02:00
Karl Mikaelsson
0c7b4117ab Enable fragmented Fast-Path Updates
Fragmented updates are concatenated into temporary streams (one per
update type) that are processed when receiving an update with the
FASTPATH_FRAGMENT_LAST bit set.
2017-10-16 14:01:13 +02:00
Karl Mikaelsson
b8a1d04ffb Use system default pointer when requested
Solves problem with hidden cursors at login screen (part of
issue #165)

Signed-off-by: Karl Mikaelsson <derfian@cendio.se>
Signed-off-by: Henrik Andersson <hean01@cendio.se>
2017-10-16 13:55:39 +02:00
Karl Mikaelsson
12ee9eb035 Avoid magic constants in caplen too 2017-10-13 14:34:01 +02:00
Karl Mikaelsson
eec94365c4 Improve Fast-Path code readability
Using constants and field definitions from MS-RDPBCGR.
2017-10-13 14:02:03 +02:00
Karl Mikaelsson
3abeca252b Log system pointer changes via Fast-Path updates 2017-10-13 14:02:03 +02:00
Karl Mikaelsson
72f63d04ec Decipher remaining capabilitysets sent from rdesktop 2017-10-13 14:02:03 +02:00
Karl Mikaelsson
9ca206bc08 Clarify order and bitmap capability set functions 2017-10-13 14:02:03 +02:00
Karl Mikaelsson
3b0a0c1334 Improve rdp_out_general_caps
Rename to rdp_out_ts_general_capabilityset to match the structure
name, describe all fields and use constants instead of magic numbers.
2017-10-13 14:02:03 +02:00
Henrik Andersson
594438e5eb Make deprecated rdp_out_unistr() static 2017-09-29 16:30:17 +02:00
Henrik Andersson
de8fe9429f Add two new stream functions for writing utf16 strings
This is the first steps of removing the old rdp_out_unistr() and
using clearer code.
2017-09-29 14:24:27 +02:00
Henrik Andersson
b872ddb21d Ran indent script 2017-06-07 09:39:29 +02:00
Henrik Andersson
b9481bb01b Fix reconnection using the cookie
The use of redirection cookie was never done due to global
g_redirect flag was cleared on the wrong place. This fixes
the problem with dual authentication prompts when redirect
to another server upon connect.

Fixes issue #18
2017-05-15 08:36:41 +02:00
Henrik Andersson
708b0f0071 Rename redirection flags matching names in specification
Also added missing flags available from spec
2017-05-15 08:03:39 +02:00
Henrik Andersson
c93960b266 Cleanup of TS_SECURITY_HEADER code
Add correct naming of header TS_SECURITY_HEADER and its flags
as per MSRDPBCGR specification.
2017-03-07 15:32:14 +01:00