Commit Graph

177 Commits

Author SHA1 Message Date
Pierre Ossman
489c43f382 Return STREAM objects from data generating functions
Use a consistent style of returning a new STREAM object from functions
that output data, rather than requiring an existing structure to be
passed in. This generally makes the memory management more straight
forward and allows us to do more proper bounds checking of everything.

This also adds some new STREAM macros to make it easier to manage
them without poking around in the internal structure.
2019-05-06 14:33:11 +02:00
Pierre Ossman
de59a100ea Mark rd_protocol_error() as "noreturn"
This allows the compiler to optimize things better and give better
warnings as it knows it will never return from this function.
2019-05-06 14:33:05 +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
Alexander Zakharov
d7d55cf3f7 PoC: Check server's certificate 2019-01-29 10:38:13 +01: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
Rostislav Kondratenko
2abd25ae2a Fix scard logon 2018-04-27 13:46:45 +03: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
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
e112b69c61 Use proper user-initiated disconnect sequence
A correct user initated disconnect sequence should send
a MCS Disconnect Provider Ultimatum PDU defined in T.128
upon a disconnect. This commit adds the implementation
the mentioned PDU and the actual write of the packet.

Signed-off-by: Henrik Andersson <hean01@cendio.com>
2018-01-31 11:03:32 +01:00
Cendio
37da672908 Added ber_out_sequence() util for writing ASN.1 sequences
Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Thomas Nilefalk <thoni56@cendio.se>
2018-01-31 11:03:32 +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
Cendio
1f3d1fb3e0 Refactor handling of user requested window sizes
Extract ui_init_connection() into smaller functions
to clarify purpose.

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
2f03f65efe Add Dynamic Virtual Channels and basic RDPEDISP support
Fix issue #192

Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Karl Mikaelsson <derfian@cendio.se>
2017-11-09 15:39:39 +01:00
Karl Mikaelsson
8f83c1f6c7 Rename suppress output functions to match MS-RDPBCGR
Issue #161
2017-10-30 10:47:21 +01:00
Henrik Andersson
0d707ae103 Fix sign-compare compiler warnings 2017-10-20 13:30:42 +02:00
Henrik Andersson
036f0fbebe Add UNUSED() macro to silent warnings
Use it to silent warning where a function parameter
is unused.
2017-10-17 09:52:42 +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
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
Henrik Andersson
594438e5eb Make deprecated rdp_out_unistr() static 2017-09-29 16:30:17 +02:00
Henrik Andersson
b25f93c0e6 Run indentation script 2017-08-15 10:50:08 +02:00
Pierre G. Bogossian
9889ed6457 Support extended mouse buttons 4 and 5 (ie back/forward buttons) 2017-07-09 16:56:30 +02:00
Henrik Andersson
87d8d123b8 Rework the logging system
This commit will add a logging system to solve the problem that
one actually need to recompile rdesktop from source to enable
different debug logging.

- Same logging api  for all kind of logging and messages to
   end user.

- Adding -v for verbose output when running rdesktop.

- All messages are logged into a subject and with a type, eg:

     logger(Keyboard, Notice, "Autos-electing %s based on locale.", locale);

- Debug logging is enabled trough a environment variable RDEKSTOP_DEBUG,
  which specifies subjects of interest, comma separated. There is a special
  subject named All which includes all subject for debug loggin. There is also
  a simple logic opeartor '!' = NOT which can be used in combination like:

    RDESKTOP_DEBUG=All,!Graphics,!Sound

  Which would give debug log output for All subject except Graphics and Sound.
2017-01-26 14:19:40 +01:00
Henrik Andersson
761cc053e2 Fixes a bug with Windows Server 2012 r2 and smartcard
redirection were the RDPDR channel is shutdown by server.

The RDPDR channel is shutdown by server when responses from
abdonend iorequests are received on a reinitialized RDPDR
channel. This fix adds epochs for RDPDR channel and tags 
iorequest to specific epoch to handle abdonend iorequest.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1836 423420c4-83ab-492f-b58f-81f9feb106b5
2014-09-11 11:54:46 +00:00
Henrik Andersson
46a3684c27 Document the new seamless protocol command PERSISTENT
and implement the usage of the new command in rdesktop.

If a seamless command is specified the persistent mode
of the session will be changed to non-persistent.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1822 423420c4-83ab-492f-b58f-81f9feb106b5
2014-07-03 10:42:04 +00:00
Henrik Andersson
2ceb56e0d4 Added seamless_reset_state() and use it whenever a
new window is created. This fixes issues with seamless
protocol parser between reconnects.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1820 423420c4-83ab-492f-b58f-81f9feb106b5
2014-07-02 08:25:07 +00:00
Henrik Andersson
7ece007132 Fix indentation...
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1778 423420c4-83ab-492f-b58f-81f9feb106b5
2013-12-12 14:01:58 +00:00
Henrik Andersson
f0b6604347 Changed rdp_in_unistr() to make dynamic allocation of converted string
instead of using hardcoded buffer sizes and assumtion that conversion
just fits the size.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1773 423420c4-83ab-492f-b58f-81f9feb106b5
2013-12-06 12:43:08 +00:00
Henrik Andersson
58363c5351 - Added rd_create_ui() helper function
- Make sure that ui is created if processing demand active PDU
- Make sure we use precached bitmap cache again

This fixes bugs #367 and #368



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1732 423420c4-83ab-492f-b58f-81f9feb106b5
2013-08-14 13:49:45 +00:00
Henrik Andersson
e6b10f6bcb Added tcp_ui_run() to prevent ui_select() push data on transport
which corrupts the stream and prevents a SSL reconnect to work.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1720 423420c4-83ab-492f-b58f-81f9feb106b5
2013-06-20 12:51:27 +00:00
Henrik Andersson
eced6ca821 Reconnect upon network failure, retry as long the autoreconnect
cookie is valid.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1707 423420c4-83ab-492f-b58f-81f9feb106b5
2013-04-12 06:46:07 +00:00
Henrik Andersson
be93803129 Intitial implementation of seamless connection sharing:
- Implementation of ctrl functionality were slaves can call
  a method into existing master process, more information is
  found in doc/ctrl.txt

- Implementation of new seamless SPAWN functionality so which
  is used by the ctrl to spawn processes in a seamless rdp session
  out of process.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1689 423420c4-83ab-492f-b58f-81f9feb106b5
2013-01-21 12:28:14 +00:00
Henrik Andersson
49d4996cd7 Added missing cssp_connect() declaration.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1682 423420c4-83ab-492f-b58f-81f9feb106b5
2012-11-29 07:42:54 +00:00
Henrik Andersson
9f174ea864 Added check if socket is connected to prevent sending disconnect
sequence to a closed socket.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1681 423420c4-83ab-492f-b58f-81f9feb106b5
2012-11-22 13:38:35 +00:00
Henrik Andersson
51014c91df Initial implementation of kerberos server autentication with CredSSP,
disabled by default and is enabled using argument --enable-credssp
to configure script.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1676 423420c4-83ab-492f-b58f-81f9feb106b5
2012-11-15 11:21:01 +00:00
Henrik Andersson
c44025aa18 Added support for protocol negotiation, this is a part of
adding Enhanced RDP Security support to rdesktop and brings
support for TLSv1 tunnel functionality.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1659 423420c4-83ab-492f-b58f-81f9feb106b5
2012-06-15 05:16:20 +00:00
Henrik Andersson
cdce9aae75 Run indentation script.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1658 423420c4-83ab-492f-b58f-81f9feb106b5
2012-01-16 06:35:13 +00:00
Henrik Andersson
8a52bf3a9b - Change licensestore to XDG directory ~/.local/share/rdesktop/licenses
- Added helper functions for SHA1 hash to hash the hostname used for
  licenses filename to hide information of what host user X connects 
  from in a infrastructure with NFS mounted home directories.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1644 423420c4-83ab-492f-b58f-81f9feb106b5
2011-11-21 10:51:08 +00:00
Henrik Andersson
161b4f215a - Remove force flag from rdpdr_init()
- Changes to always start the rdpdr channel
  due assumtions that this channel is supposed
  to always be up and running.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1607 423420c4-83ab-492f-b58f-81f9feb106b5
2011-01-03 13:12:17 +00:00
Henrik Andersson
9dd6bdab95 Fix for sound playback in Windows 2008R2 which requires
the rdpdr channel to be initiated. 
RDPEA nor RDPBCGR mention a relation between audio and
the rdpdr channel.

See. support request #2717082



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1604 423420c4-83ab-492f-b58f-81f9feb106b5
2010-12-20 13:42:51 +00:00
Peter Åstrand
42928d7ae1 Properly reset sound subsystem when reconnecting due to screen size
change (RandR). 



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1592 423420c4-83ab-492f-b58f-81f9feb106b5
2010-04-09 13:12:31 +00:00
Peter Åstrand
60e82d86ef Reset smart card state before reconnect. This fixes stability problems
when using smart cards in conjunction with RandR. 



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1561 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-26 12:23:53 +00:00
Peter Åstrand
564175719c Need two more smart card prototypes, to avoid warnings.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1558 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-26 10:13:53 +00:00
Peter Åstrand
6ee9faeffc Added RandR support: If the specified geometry depends on the screen
size, and the screen size is changed, rdesktop will automatically
reconnect using the new screen size. This feature uses the previously
implemented autoreconnect feature. 

The new UI function ui_seamless_end() has been introduced, to make it
possible to resize in seamless mode as well. 



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1556 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-20 09:59:47 +00:00
Peter Åstrand
ea2bdbc96b This patch is a re-work of patch r1538. One one hand, the plain old
behaviour of setting the session size in ui_init is not going to work,
due to xrandr, as pointed out in r1538. However, the approach
implemented in this revision doesn't work either: When the window is
created before the connection, this means that as soon as X11 events
are recieved, this is going to trigger RDP transmissions. For example,
a call to reset_modifiers_keys. But if the RDP connection is not
ready, the WTS is not prepared to handle such data. We must wait with,
for example, keyboard input until the connection is READY. OTOH, we
can't just ignore those X11 events; that might lead to that we are not
sending information that we need to send. 

So, it is actually better to wait with creating the window until we
have been connected. An additional advantage of this is that for the
load balancing / session directory case, there's no risk of confusion
of which RDP connection we are actually sending data to. 

The previous behaviour of creating the window after we have been
connected has been restored.

Since we still need to set connection data (currently screen size) on
a per connection basis, we need to create a new UI function for this.

Non-X11 backends need to implement this new function. 



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1545 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-13 13:51:06 +00:00
Peter Åstrand
281d7c9f06 Changed license to GPLv3
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1534 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-12 08:31:06 +00:00
Peter Åstrand
440542c535 Elminate code duplication in rdp_reconnect and sec_connect.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1528 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-07 20:01:58 +00:00
Peter Åstrand
d00373436a Avoid code duplication in iso_connect/iso_reconnect.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1526 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-07 18:42:47 +00:00