Commit Graph

263 Commits

Author SHA1 Message Date
akallabeth
33827cb920 Updated RDP state machine
* More detailed states
* Better transition checks
* No more recursive calling of state machine functions
2022-11-11 11:51:27 +01:00
akallabeth
06c2ab76e0 Remove AwaitCapabilities 2022-11-11 11:51:27 +01:00
akallabeth
2ef506cff2 Better checks on activation received
Check for reactivation, remember resolution, ...
2022-11-04 14:46:58 +01:00
akallabeth
b9e701aa3d Added return value for rdp_write_header 2022-11-04 14:46:58 +01:00
David Fort
ef1a3b0af6 client: improve connection time
The old code was looping with blindly checking for transport events, and then
sleep for 100 ms. It was doing that until the connection is established or
the timeout expired.
The new version polls the transport's events, potentially not having many 100 ms
waits.
2022-11-04 09:50:31 +01:00
akallabeth
7d67adbc54 Refactored licensing module
* Make the whole module opaque for easier testing
2022-11-03 17:02:47 +01:00
Marc-André Moreau
e3594c91dc Add UserSpecifiedServerName setting, /server-name command-line parameter 2022-10-14 17:59:57 -04:00
Armin Novak
a3ec857278 Improved MCS checks, added settings to MCS function 2022-10-13 13:57:11 +02:00
Armin Novak
d0ae1c8160 Moved pubSub to rdpRdp 2022-07-06 12:01:23 +02:00
Armin Novak
29af8a45b6 Fixed missing LoadChannels calls and settings on redirect 2022-06-27 14:27:12 +02:00
akallabeth
43b1f51984 Unified setting of finalize_sc_pdus 2022-06-23 14:19:50 +02:00
akallabeth
bc8b4ade1c reformatted 2022-06-23 08:48:39 +02:00
akallabeth
73cdcdfe09
Logging and parser fixes (#7796)
* Fixed remdesk settings pointer

* Fixed sign warnings in display_write_monitor_layout_pdu

* Use freerdp_abort_connect_context and freerdp_shall_disconnect_context

* Added and updates settings

* info assert/dynamic timezone

* mcs assert/log/flags

* Fixed and added assertions for wStream

* Unified stream length checks

* Added new function to check for lenght and log
* Replace all usages with this new function

* Cleaned up PER, added parser logging

* Cleaned up BER, added parser logging

* log messages

* Modified Stream_CheckAndLogRequiredLengthEx

* Allow custom format and options
* Add Stream_CheckAndLogRequiredLengthExVa for prepared va_list

* Improved Stream_CheckAndLogRequiredLength

* Now have log level adjustable
* Added function equivalents for existing logger
* Added a backtrace in case of a failure is detected

* Fixed public API input checks
2022-04-19 14:29:17 +02:00
Armin Novak
eebb0c59b0 Removed rdpRdp instance pointer 2022-03-29 12:13:37 +02:00
akallabeth
d3ae821477 Improved logging, compiler warning fixes
* Improved logging in TPKT, TPDU, MCS, PER
* Proper use of rdpSettings functions
* Fixed missing return values
* Refactored rdp_server_transition_to_state
2022-03-28 15:52:32 +02:00
akallabeth
fa3cf9417f
Fixed #7696: Abort freerdp_connect if manually canceled (#7700)
If freerdp_abort_connect is called, set FREERDP_ERROR_CONNECT_CANCELLED
This way freerdp_reconnect can distinguish between network issues and
user interaction and abort a retry attempt.
2022-03-07 13:47:43 +01:00
Armin Novak
4d03d7c0bf Freerdp remove #ifdef HAVE_CONFIG_H 2022-03-03 11:26:48 +01:00
Armin Novak
b2ad47a809 Reorganized FreeRDP headers 2022-03-03 11:26:48 +01:00
Armin Novak
cefb4e1237 Use freerdp_settings_set and _strdup 2022-02-02 13:43:31 +00:00
Armin Novak
10e40147fb Fixed various const warnings 2022-02-01 10:25:37 +00:00
akallabeth
feb6d9ae5c
Set last error on activation timeout (#7502) 2021-12-17 17:28:41 +01:00
Armin Novak
d248b635a5 Added Redirect callback 2021-12-15 14:38:13 +01:00
Armin Novak
b545094664 Cleaned up redirection code 2021-12-15 14:38:13 +01:00
Armin Novak
18a3fcf2fc Updated wStream API and added torough checks
* Do length/capacity checks in every read/write/seek function
  if WINPR_ASSERT is defined.
* Ensure s->pointer is valid, e.g. within s->buffer + s->capacity
  (Stream_Rewind, Stream_Seek, ...)
* Add return values to Stream_Set* functions so inalid arguments
  can be reported to the caller
* Deprecated problematic stream manipulation functions
  (Stream_SetBuffer, Stream_SetPointer, Stream_SetCapacity)
* Ensure length/capacity functions never return a value larger
  than the actual length/capacity
2021-10-06 09:49:07 +02:00
akallabeth
03a9ca80c8
Refactor proxy (#7312)
* Added hidden transport dump and replay options

* Added settings to enable transport dump and replay
* Added check in freerdp_connect to skip authentication on
  dump replay

* Fixed proxy issues

* Proper shutdown handling
* Uninitialized variables
* Skip proxy-client channels, initialize from peer channels and
  config
* Filter static channels like dynamic ones
* Added proxy module filtering from config data (channels, input, ...)

* Removed oboslete proxy decoding related files

* Added defines for RDPECAM channel

* Added proxy config options:

* VideoRedirection
* CameraRedirection

* Fixed duplicate channel free
2021-09-23 14:52:03 +02:00
akallabeth
e0a531f728
Channel fixes (#7309)
* Added missing CHANNEL_NAME defines.

* Fixed FreeRDP_ChannelDefArray setter

* Fixed code duplication due to merge error

* Added public function freerdp_channels_from_mcs

* Fixed const correctness in mcs
2021-09-22 14:27:21 +02:00
akallabeth
1ca7e1f7a0 Added option to disable graphics decoding in client code path 2021-09-20 10:59:59 +02:00
akallabeth
1904020d7f
Some code cleanups and WINPR_ASSERT (#7281) 2021-09-10 09:06:35 +02:00
Armin Novak
56648a98f2 Fixed rdp_reset error handling 2021-09-09 08:53:20 +02:00
Armin Novak
17f530a866 Transport opaque 2021-09-09 08:36:01 +02:00
akallabeth
d7d7c45b0e Cleaned CONNECT_STATE transition function 2021-09-06 10:11:14 +02:00
akallabeth
32b3f54bb3 Expose CONNECTION_STATE via public API
* Expose type CONNECTION_STATE
* Add getter freerdp_get_state
* Add helper freerdp_state_string
2021-09-06 10:11:14 +02:00
akallabeth
00ac11524e Wrapped rpdRdp:state access in getter/setter
* Only access state via getter/setter
* Better state debuggind with log messages on state transition
2021-09-06 10:11:14 +02:00
akallabeth
617293e0d3
Cleanups (#7239)
* Use freerdp_settings_* for shadow and sample server

* Added freerdp_peer_set_local_and_hostname

* Code cleanups and WINPR_ASSERT

* Code cleanups

* Use CHANNEL_NAME_LEN where appropriate
* Use temporary variables in loop instead of direct array access
2021-08-24 14:09:40 +02:00
akallabeth
8d82adb28a Fixed warnings 2021-06-17 10:35:22 +02:00
sss
6b76ac9545 Revert "Revert "allow to use in single threaded mode" (#6864)"
This reverts commit f7465af44f.
2021-03-26 11:50:45 +01:00
akallabeth
f7465af44f
Revert "allow to use in single threaded mode" (#6864)
This reverts commit bee2e1526d.
2021-03-05 13:02:38 +01:00
Gluzskiy Alexandr
bee2e1526d allow to use in single threaded mode
(some client side channels and all server side channels still need to be
ported to new api)

server: build fix, do not disable threads for rfx encoder

cliprdr client channel: implemented support for DisableThreads option
looks like thread does not make sense at all for this channel

do not initialize disabled image codecs (respect settings)

channels: client: rail: added support for DisableThreads setting

changed "BOOL DisableThreads" to "UINT32 ThreadingFlags"
dropped unnecessary apu changes

draft implementation of threading settings aware message handling api
for addins/channels

rail: use new messaging api

fixed memory leak

msgs handlers external api changes (as requested)

msgs_handlers: init fix

fixed memory leak

logic fix

resolved problems appeared after rebase to master, dropped unnecessary
changes

git clang-format origin/master

fixed TestFreeRDPCodecRemoteFX.c

"formatting, run `clang-format` please"

properly use new "rfx_context_new(BOOL, UINT32)" everywhere

passed Threading Flags to "rfx_context_new" where available

in older C standarts veriables declaration must be done before any code

requested changes

clang-format as requested

use broken signatures of standert C functions for m$ s**tos

clang-format

requested changes

requested changes

moved ThreadingFlags to stable api zone

define type for channel msg handler

typo fix

clang-format

build fix

us ThreadingFlags from server settings

git clang-format origin/master

clang-format
2021-02-25 14:05:40 +01:00
Armin Novak
f9c2d5bab9 Added ConnectionStateChangeEvent for clients
Clients can now subscribe to connection state change events to
prevend data from being transmitted on sessions being redirected.
2021-02-11 10:41:28 +01:00
akallabeth
102869f6a8 Fixed missing check for fastpath input messages
Input events are only allowed after a connection was established
(connection state is active)
This check aborts input sending when done before that.
2021-01-23 16:12:29 +01:00
Armin Novak
c7187928e9 Fix tpkt header length checks for encrypted packets
If securityFlag SEC_ENCRYPT is set, remove the encryption headers from
the TPKT header length on comparison.
2020-03-10 12:20:50 +01:00
Armin Novak
be714d2a13 Fixed tpkt header length checks.
TPKT header length and consumption of data was not consistently
checked. This adds checks after each packet processed and fixes
any inconsistencies found.
2020-03-02 11:40:35 +01:00
Armin Novak
318cb3dd47 Added tpkt header length plausibility checks. 2020-03-02 11:40:35 +01:00
Norbert Federa
a48e7f8b47 core: fix endless loops waiting for activation
There are two loops polling the transport pdu receiver in non-blocking mode
when waiting for reaching CONNECTION_STATE_ACTIVE rdp state.

In case of an invalid pdu size in the tpkt header this leaded to an endless
loop, utilizing 100% of a cpu core.

Added a sleep and limited the max loop time to the tcp ack timout value.
2020-02-20 17:51:20 +01:00
Armin Novak
9d65d9562b Fixed missing NULL set of pointer after free
Due to this double free was possible if disconnect_and_clear was
called multiple times.
2020-01-21 14:44:21 +01:00
Armin Novak
895cb8f944 Added macro freerdp_set_last_error_if_not
This macro replaces the multiple instances where the current
error state is checked before setting an optional error state.

Signed-off-by: Armin Novak <armin.novak@thincast.com>
2020-01-09 10:34:27 +01:00
Armin Novak
7d252cdc8e Added freerdp_set_last_error_ex function
This new function allows better logging of call locations
for errors. Additionally added freerdp_set_error_log macro
to record function, file and line the error was set.

Signed-off-by: Armin Novak <armin.novak@thincast.com>
2020-01-08 17:39:25 +01:00
Armin Novak
7c243da6e1 Remove symbols exported by accident. 2019-12-02 10:57:31 +01:00
Armin Novak
72ca88f49c Reformatted to new style 2019-11-07 10:53:54 +01:00
Armin Novak
441fb4d0ca Allow freerdp clients to function with WITH_OPENH264_LOADING
If no library can be loaded at runtime ignore H264 capabilities.
This allows a build with only OpenH264 support and dynamic loading
enabled to function when no openh264 library was detected.
2019-10-07 09:31:20 +02:00
Armin Novak
19103fee3d Only try to set nego token if load balance info length is >0 2019-07-02 11:53:14 +02:00
Armin Novak
295ac3daa4 Fixed dead store warnings 2019-04-05 09:14:35 +02:00
Armin Novak
f65b94ed84 Yield in connection wait loops to reduce processor use.
Patch by Andrey Vasilkin on mailing list.
2019-01-18 13:03:36 +01:00
Armin Novak
8110c391bf Fixed requested protocol define names according to spec. 2018-12-05 10:55:06 +01:00
Armin Novak
5ca8eca18e Made nego self contained. 2018-12-05 10:55:06 +01:00
Martin Fleisz
6c97d318ec
Merge pull request #5022 from akallabeth/gw_rdg_error_mapping
Improved error mapping and tightened checks in rdg_process_packet
2018-11-22 15:10:58 +01:00
Armin Novak
666ef4ab34 Fix #4864: Register pointer cache after PostConnect is called
With #4950 client side pointer implementation was made optional.
This addresses an issue that each client had to call
pointer_cache_register_callbacks on its own.
2018-11-20 09:49:39 +01:00
Armin Novak
7839091f8b Skip redirection resolve test if we're connecting via gateway. 2018-11-16 15:48:10 +01:00
Armin Novak
47ba37fbcb Unified dns resolving of host 2018-09-27 16:08:28 +02:00
Armin Novak
13e59b5d6a Fix #4868: Allow empty bands data. 2018-09-19 14:18:29 +02:00
Armin Novak
13564dbb41 Allow redirect address override with a list of values. 2018-08-08 12:30:47 +02:00
Armin Novak
cc5e402cda Added command line option /redirect-prefer:<fqdn|ip|netbios>
Since redirection sometimes happens with internal DNS names that
are resolved different by outside DNS it must be possible to override
the preferred redirection hint.
2018-08-08 11:24:13 +02:00
Armin Novak
f6b6eba0ab Try redirection FQDN first, but check if it is resolvable. 2018-08-08 10:25:09 +02:00
Armin Novak
3a30844db8 Added default return value. 2018-07-31 10:45:04 +02:00
Armin Novak
7a6b8a04b9 Fixed channel reconnect after redirect. 2018-07-13 13:11:38 +02:00
Armin Novak
77eb93b4b7 Made internal functions static to help compiler optimize. 2018-07-10 12:21:38 +02:00
Armin Novak
7a39dcd7e2 Updated reconnect to handle cases where PostConnect was not called
freerdp_reconnect might be called after a freerdp_connect failed due
to a TCP timeout waiting for user input.
In such cases we need to know if PostConect was already called and
do that if not.
2018-07-10 12:04:27 +02:00
Armin Novak
35cd438eca Added enum for client connection state. 2018-06-25 09:25:27 +02:00
Armin Novak
273655a850 Follow up fix for #4631
Remember the callback state to avoid calling reerdp_channels_post_connect
before the corresponding client callback has benn called.
This might happen during redirection and reconnection.
2018-06-18 10:44:35 +02:00
Armin Novak
e1ea441275 Fixed #4629: Only call freerdp_channels_post_connect when it was connected.
In rdp_client_redirect or rdp_client_reconnect freerdp_channels_post_connect must
be called if the channels were connected previously.
This might not be the case, skip that call then.
2018-05-11 10:49:29 +02:00
David Fort
8cba201999
Merge pull request #4548 from akallabeth/autoreconnect_fix
Autoreconnect fix
2018-04-27 09:39:30 +02:00
Armin Novak
1feca7768e Fixed redirection with session brokers.
* Only reconnect channels on redirect, if they have already been connected.
* Prefer TargetNetAddress over FQDN to connect.
2018-04-16 16:46:48 +02:00
Armin Novak
685f5a8d20 Do not clear last error if not reconnecting. 2018-04-11 10:06:11 +02:00
Armin Novak
2fc31fcb37 Set connection error if TCP connect fails. 2018-04-11 09:09:23 +02:00
Armin Novak
7af9ba9171 Refactored reconnect and redirect API
Reconnect and redirect share the same code on disconnect.
Move that to a single function and export it as it may be required
to terminate the session properly before reconnect is called.
2018-04-09 14:04:30 +02:00
Armin Novak
0a7691de58 Fixed channel (dis)connect on redirect or reconnect. 2018-04-09 11:26:12 +02:00
KOVACS Krisztian
6518e36c70 Revert "core/connection: use redirection password when reconnecting"
This reverts commit 70c65e70d1.
2017-12-06 14:58:34 +01:00
Ondrej Holy
6973b14eed Enable FIPS mode automatically
FreeRDP aborts if OpenSSL operates in FIPS mode and +fipsmode is not
manually specified. Let's prevent the abortion and enable the necessary
options in that case automatically.
2017-11-23 10:09:17 +01:00
Brent Collins
d98b88642b Add new command-line option to force xfreerdp into a fips compliant mode.
This option will ensure that NLA is disabled(since NTLM uses weak crypto algorithms), FIPS
encryption is enabled, and ensure fips mode is enabled for openssl.

Selectively override specific uses of MD5/RC4 with new API calls specifically tailored to override FIPS.

Add comments on why overriding the use of these algorithms under FIPS is acceptable for the locations where overrides happen.

Remove check of server proprietary certificate which was already being ignore to avoid use of MD5.

Initialize winpr openssl earlier to ensure fips mode is set before starting using any crypto algorithms.
2017-11-17 12:43:06 +01:00
KOVACS Krisztian
70c65e70d1 core/connection: use redirection password when reconnecting
According to MS-RDPBCGR the server might send a password in the Redirection PDU
that then must be sent by the client to the server as password.

Since the field either contains a password string (unicode) or a binary cookie,
we try to convert the password from unicode and use it only if conversion
succeeds.
2017-11-09 14:46:38 +01:00
Armin Novak
0490aeb018 Fixed clang malloc integer overflow warnings. 2017-07-20 09:29:48 +02:00
Armin Novak
8292b4558f Fix TALOS issues
Fix the following issues identified by the CISCO TALOS project:
 * TALOS-2017-0336 CVE-2017-2834
 * TALOS-2017-0337 CVE-2017-2834
 * TALOS-2017-0338 CVE-2017-2836
 * TALOS-2017-0339 CVE-2017-2837
 * TALOS-2017-0340 CVE-2017-2838
 * TALOS-2017-0341 CVE-2017-2839
2017-07-20 09:28:47 +02:00
Armin Novak
8c52dcbdc2 SEC_ENCRYPT check in rdp_client_connect_auto_detect
Fix by @wizwizaco for #3951
2017-05-15 13:10:10 +02:00
Armin Novak
9f9254504e Fixed leak of client random. 2017-03-28 14:33:02 +02:00
David Fort
b0b3a78a20 Store client_random in server mode
We need the client_random in server mode when the client does RDP security and
tries to reconnect using the cookie.
2017-03-21 10:32:17 +01:00
David Fort
7b437178bb Add a ClientCapabilities callback
This callback is called when the client capabilities have been received. This callback
appears to be more useful than the Capabilities one that is called just before the server
sends its capabilities.
2017-02-21 23:44:47 +01:00
Martin Fleisz
68a9408249 core: Get rid of useless settings copy 2017-02-15 14:59:24 +01:00
Norbert Federa
f71b6b46e8 fix string format specifiers
- fixed invalid, missing or additional arguments
- removed all type casts from arguments
- added missing (void*) typecasts for %p arguments
- use inttypes defines where appropriate
2016-12-16 13:48:43 +01:00
Armin Novak
a1b2325c1d Ensure securityFlags are always initialized. 2016-12-02 12:04:53 +01:00
Norbert Federa
53bd98883e winpr/crypt api changes and memory leak fixes
- winpr_HMAC_New() now just returnes the opaque WINPR_HMAC_CTX* pointer
  which has to be passed to winpr_HMAC_Init() for (re)initialization
  and since winpr_HMAC_Final() no more frees the context you always have to
  use the new function winpr_HMAC_Free() once winpr_HMAC_New() has succeded

- winpr_Digest_New() now just returns the opaque WINPR_DIGEST_CTX* pointer
  which has to be passed to winpr_Digest_Init() for (re)initialization
  and since winpr_Digest_Final() no more frees the context you always have to
  use the new function winpr_Digest_Free() once winpr_Digest_New() has succeded
2016-11-24 18:27:29 +01:00
Norbert Federa
7befab856c Support for OpenSSL 1.1.0 2016-11-24 17:50:09 +01:00
Marc-André Moreau
1ffbd774e9 freerdp: fix sending of TLS alert on NLA failure, add better handling of server-side NLA in shadow server 2016-07-21 17:53:20 -04:00
Norbert Federa
6ee445339b core: fix broken rdp security (server side)
- fixed typo in rdp_server_establish_keys
2016-04-08 14:47:35 +02:00
Armin Novak
36cbf1b583 Fixed error handling for channel load failures. 2016-03-14 13:13:43 +01:00
Armin Novak
b429d230cb Refactored crypto *_New functions. 2016-02-29 09:00:02 +01:00
Armin Novak
92c15783dc Updated RC4 API, fixed crashing bug. 2016-02-28 11:19:29 +01:00
Armin Novak
238ff3b315 Unified encryption functions. 2016-02-27 23:28:49 +01:00
Armin Novak
5805ba8e52 Removed crypto_nonce. 2016-02-27 22:40:43 +01:00
Armin Novak
f997421098 Unified hmac functions. 2016-02-24 21:50:08 +01:00
Armin Novak
ada2b16c50 Unified RC4 functions. 2016-02-24 17:04:03 +01:00