Commit Graph

320 Commits

Author SHA1 Message Date
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
c6924cb126 Moved clipboard utils to core library, fixes #6760 2022-03-28 14:59:30 +02: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
akallabeth
8cc6582044
Unify struct definitions (#7633)
* Unified enum/struct definitions, fixed include issues

* Fixed mac compilation issues

* Added missing include

* Fixed windows server build warnings

* Fixed VS2010 build issue

* Removed unnecessary library linking

* Fixed ThreadPool WinXP compatibility

* Fixed pr review remarks
2022-02-14 14:59:22 +01:00
akallabeth
2422985f2a Fixed cliprdr_parse_file_list 2022-02-05 14:06:08 +00:00
akallabeth
4a4d783d4f
Moved clipboard custom context checks to implementation (#7501) 2021-12-17 13:47:20 +01:00
akallabeth
3ccb96d52f Fixed #7350: Warnings with Stream_StaticInit
* Properly initialize the stream buffer
* Add Stream_StaticConstInit accepting a const buffer
* Modify API to return a pointer to the stream initialized
2021-10-14 12:11:16 +02:00
akallabeth
7b7e2d6f32 Prefer constant division over multiplication for length checks 2021-09-21 08:55:22 +02:00
Armin Novak
cde002f460 Cleaned up cliprdr 2021-09-09 08:53:20 +02:00
Armin Novak
467f7c3f6a Fixed proxy ulimit graceful client disconnect 2021-09-09 08:53:20 +02:00
Armin Novak
054f0ea260 Use defines instad of channel names 2021-08-25 10:54:24 +02:00
Biswapriyo Nath
173ab04b59 Use same data types as calling function prototypes. 2021-05-31 13:38:19 +02:00
Marc-André Moreau
841d019565 fix broken channel include path 2021-05-31 11:10:14 +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
akallabeth
f3dad4106a Fixed support for huge files in clipboard 2021-01-25 08:43:46 +01:00
akallabeth
d11422b6b8 Added missing include. 2020-11-18 07:18:25 +01:00
akallabeth
e4243bb33c Corrected clipboard capability mask 2020-10-02 13:17:00 +02:00
akallabeth
f282c55c7a Added clipboard CB_HUGE_FILE_SUPPORT_ENABLED flag 2020-09-29 09:03:49 +02:00
akallabeth
1546a8b655 Fixed naming of FILEDESCRIPTORW 2020-09-18 12:49:54 +02:00
Zhu Qun-Ying
2ba7f9da1d cliprdr_common.c: fix memory leak in certain error condition 2020-07-25 16:55:34 +02:00
Zhu Qun-Ying
2a286fbf65 Fixed error msg typo in ciprdr_main.c 2020-07-25 16:55:21 +02:00
akallabeth
58ef235bc5 Removed unused variable warnings 2020-05-20 15:10:07 +02:00
akallabeth
c6e37dce79 Fixed #6162: Clipboard temporary path length limit
The limit of clipboard temporary paths is 260 '\0' terminated
wide characters. Fix the checks to enforce that properly.
2020-05-12 12:16:00 +02:00
akallabeth
cbee45aace Fixed clipboard 'called with invalid type' warning 2020-05-06 13:31:57 +02:00
akallabeth
8ec50b6cc1 Fix short format name configuration and format list return. 2020-05-06 13:31:57 +02:00
akallabeth
b230ac98e9 Fixed oob read in cliprdr_read_format_list 2020-05-06 13:31:57 +02:00
akallabeth
8e1a1b4075 Fixed cliprdr_server_receive_capabilities
Thanks to hac425 CVE-2020-11017, CVE-2020-11018
2020-05-06 13:31:57 +02:00
Armin Novak
d2aef75004 Fix #5852: handle CHANNEL_EVENT_WRITE_CANCELLED
When channels are cleaned up OpenHandle is most of the time
already 0. Ignore the argument checks for
CHANNEL_EVENT_WRITE_CANCELLED and CHANNEL_EVENT_WRITE_COMPLETE
only check where actually required (CHANNEL_EVENT_DATA_RECEIVED)
2020-01-29 08:52:25 +01:00
Armin Novak
7c243da6e1 Remove symbols exported by accident. 2019-12-02 10:57:31 +01:00
kubistika
511f89cd99 cliprdr: common: fix validation of file contents request pdu 2019-11-12 12:45:01 +01:00
Armin Novak
72ca88f49c Reformatted to new style 2019-11-07 10:53:54 +01:00
Armin Novak
75ed12f1f0 Fixed userdata pointer and CHANNEL_EVENT_WRITE_CANCELLED message. 2019-11-06 13:01:43 +01:00
Armin Novak
1bcb799560 Listen to CHANNEL_EVENT_WRITE_CANCELLED and emit if queue is cleared. 2019-11-06 13:01:43 +01:00
Armin Novak
1b78b59926 Fixed #4809: Properly process CHANNEL_EVENT_WRITE_COMPLETE 2019-11-06 13:01:43 +01:00
Armin Novak
f01e042211 Code cleanups (strlen, casts, size_t, ...) 2019-10-29 11:58:43 +01:00
kubistika
5cc5aa98ec channels: cliprdr: client: fix leak in cliprdr_packet_send 2019-10-18 14:20:26 +02:00
kubistika
d75c5eec04 channels: cliprdr: improved common cliprdr api 2019-10-18 14:20:26 +02:00
kubistika
d2f73136d3 channels: cliprdr: reformat cliprdr_common.c 2019-10-18 14:20:26 +02:00
kubistika
345cc2a2f5 channels: cliprdr: get rid of duplicated server and client code 2019-10-18 14:20:26 +02:00
Armin Novak
83b80f64af Fixed uninitialized variable warning. 2019-09-03 08:55:29 +02:00
Armin Novak
c1d98d7e0a Proper parsing of clipboard capability sets. 2019-08-19 09:30:40 +02:00
Armin Novak
74cffef053 Clipboard server callback arguments const 2019-08-19 09:30:40 +02:00
kubistika
f429275f86 channels: cliprdr: server: add autoInitializationSequence 2019-08-19 09:30:40 +02:00
kubistika
cf474bdb74 channels: cliprdr: server: call ClientCapabilities callback 2019-08-19 09:30:40 +02:00
kubistika
6cebbc2a16 channels: cliprdr: add lastRequestedFormatId
This one is for proxy use. The proxy must know what format is requested by the other side
of the connection, for determining if the message should be passed
or ignore (for example, if we want to allow only text, the proxy must
verify that the requested format received in Format Data Request PDU is
a text format.
2019-08-19 09:30:40 +02:00
David Fort
7ae72ee512
Merge pull request #5240 from akallabeth/sign_compare_fixes_v2
Sign compare fixes v2
2019-04-05 14:13:03 +02:00
Armin Novak
9218712ecf Remove unnecessary clipboard data copy. 2019-04-05 10:04:36 +02:00
David Fort
e0d60a0310 clipboard: correctly handle flags during renegociatiion (#5323) 2019-04-05 09:36:53 +02:00
Armin Novak
4360033405 Fixed const free warning. 2019-04-05 09:13:24 +02:00
Armin Novak
426137a7f0 Fixed sign-compare warnings 2019-04-05 09:13:24 +02:00
Armin Novak
65812bdbc0 Clipboard data pointer arguments are now const. 2019-01-23 16:55:13 +01:00
Armin Novak
81a0cd7010 Fixed clipboard channel cleanup. 2018-11-28 11:40:57 +01:00
Armin Novak
114abad767 Removed use of strcpy. 2018-08-27 14:34:09 +02:00
Armin Novak
a716dc244c Removed duplicate resource free. 2018-06-18 10:23:57 +02:00
Armin Novak
75717411df Fixed channel duplicate disconnect handling 2018-04-09 11:26:21 +02:00
Armin Novak
2517755d25 Fixed thread function return and parameters. 2018-03-07 14:36:55 +01:00
David Fort
41823080f9 Fix users of Stream_GetPosition() that returns size_t 2017-12-11 22:38:58 +01:00
David Fort
a5af2cc865 clipboard: add some checks for the message 2017-11-23 17:37:55 +01:00
Armin Novak
523a881663 Channels with a context must free it themselves. 2017-07-28 08:39:51 +02:00
Armin Novak
8b9e3fa51e Fixed use of reserved keywords for include guards. 2017-07-20 09:35:41 +02:00
ilammy
75fa3ad2a0 channels/cliprdr: avoid possible integer overflow
If the server sends us garbage (or the client provides it) then it is
possible for the multiplication to overflow (as it is performed on
unsigned 32-bit values) which will result in a false positive failure of
the sanity check. Avoid it by rearranging arithmetics a little.

Keep the multiplication in the error message because we are interested
in the number of bytes in the stream and how it compares to the number
we have expected based on the presumed file count.
2017-06-01 16:05:07 +03:00
ilammy
843ab1c234 winpr: fix field names of FILEDESCRIPTOR struct
The file name field is actually called cFileName on Windows. Use this
name in WinPR's struct definition as well for compatibility.
2017-04-21 14:13:52 +03:00
ilammy
a1128872d3 channels/cliprdr: handle cliprdr 2 GB size limit
The file contents PDUs support 64-bit file sizes and offsets, but
MS-RDPECLIP explicitly says in 2.2.5.3 File Contents Request PDU that
file larger that 4 gigabytes are not supported by the server. It turns
out that the supported size is even lower than that. The server cannot
correctly handle files larger than 2 gigabytes (inclusive). When faced
with such files it correctly retireves the lower part, but fails to
accept any data past that boundary. After receiving a file range reply
the server repeats the file range request with the same offset, and
again, and again, and again, making no progress and blocking the file
transfer indefinitely. This is not the behavior we would like to have.

Microsoft support site acknowledges and documents the issue [1],
suggesting the users to use disk drive redirection instead to transfer
large files. (File transfers via cliprdr are considerably slower than
disk drive redirection so the suggestion makes very much sense.)

However, we would like to avoid the lockdown of the remote session if
the user does attempt to transfer such files so we add a size check.
Putting it into the conversion from FILEDESCRIPTOR to CLIPRDR_FILELIST
is not an ideal place (the clients may not use the common utilities),
but that's good enough currently.

[1]: https://support.microsoft.com/en-us/help/2258090
2017-04-09 03:15:49 +03:00
ilammy
f643a95820 channels/cliprdr: fix CLIPRDR_FILECONTENTS_RESPONSE
Do not try to 'helpfully' fixup the length of the data provided by the
client when FILECONTENTS_SIZE is present. This can lead to a crash if
the client wants to report an error in msgFlags, sets cbRequested to
zero, and does not provide any data in requestedData. For example,
XFreeRDP does this in xf_cliprdr_send_file_contents_failure() and
xf_cliprdr_clipboard_file_size_failure().
2017-04-09 03:15:49 +03:00
ilammy
ef4421fc77 channels/cliprdr: fix CLIPRDR_FILECONTENTS_REQUEST
clipDataId is an optional field of CLIPRDR_FILECONTENTS_REQUEST.
The client should not send it to the server without sending a prior
CLIPRDR_LOCK_CLIPDATA request. The reverse is true as well: the
server should not include these additional 4 bytes without locking
the file in question.

The value zero is a valid ID, it cannot be used as a sentinel value.
Introduce a separate flag to tell whether the clipDataId has been set
and can be relied upon.

Also fix formatting. These stupid line breaks have negative impact on
readability, and the lines do fit into the 100 column limit either way.
2017-04-09 03:15:49 +03:00
ilammy
a992743d99 channels/cliprdr: CLIPRDR_FILELIST utilities
The format is described in MS-RDPECLIP 2.2.5.2.3 Packed File List
(CLIPRDR_FILELIST). These functions handle conversion between the
on-the-wire data from cliprdr and arrays of FILEDESCRIPTOR structs.

FILETIME handling is a bit wacky, but that's what we currently have.
2017-04-09 03:15:48 +03:00
Armin Novak
b2c29158be Scanbuild warning, argument checks and leak fixes.
* Added Stream_GetRemainingCapacity to check remaining stream size
  before writes.
* Fixed shadow server memory leak.
* Fixed lots of scanbuild warnings
* Added missing argument checks in many functions
* Added missing static function declarations
2017-03-02 18:13:43 +01:00
Ilya Shipitsin
4af2f71cf4 resolve compiler warning
channels/cliprdr/client/cliprdr_main.c:121:13: warning: ‘cliprdr_print_general_capability_flags’ defined but not used [-Wunused-function]

 static void cliprdr_print_general_capability_flags(UINT32 flags)

             ^
2017-02-22 20:39:32 +05: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
Norbert Federa
c6e6b44143 countless WLog/printf format specifier fixes 2016-11-25 17:06:25 +01:00
Martin Haimberger
7fe28a8a78 virtualChannel: removed static variable usage from
VirtualChannelApi
2016-11-23 04:17:56 -08:00
Martin Haimberger
d29848f383 rdpsnd: using new VirtualChannelEx api 2016-11-23 03:50:22 -08:00
Martin Haimberger
3daf4f6c53 cliprdr: using new VirtualChannelEx api 2016-11-22 02:33:23 -08:00
Marc-André Moreau
dee76617d9 channels: remove thread-local storage usage 2016-11-15 11:41:01 -05:00
Marc-André Moreau
70c4646722 channels: restore global tables for initHandle, openHandle mappings instead of thread local storage 2016-11-14 15:23:05 -05:00
Armin Novak
943e295714 WLog using C99 compatible variadic macros. 2016-10-07 14:05:27 +02:00
Armin Novak
9f5da483dc Reformatted files touched in last 2 commits. 2016-10-06 13:43:12 +02:00
Armin Novak
64590e7e89 Set pEntryPointsEx->ppInterface NULL on error. 2016-10-06 13:43:12 +02:00
Armin Novak
88a3b8dd76 Initializing channel context in each thread. 2016-10-06 13:43:12 +02:00
Armin Novak
dadc5262ae Removed static channel variables.
Global static variables do not work, if more than one instance
of an RDP client is running in the same process space.
Removed the varaibles where possible and replaced them with
thread local storage where necessary.
2016-10-06 13:43:09 +02:00
Armin Novak
8917a3da95 Fix CB_FILECONTENTS_REQUEST message decoding.
Do not require optional fields to be present as required by
[MS-RDPECLIP] 2.2.5.3 File Contents Request PDU (CLIPRDR_FILECONTENTS_REQUEST)
2016-04-19 16:47:44 +02:00
Armin Novak
2dbc1a0b87 Reverted WTS API changes. 2016-03-14 13:19:08 +01:00
Armin Novak
36cbf1b583 Fixed error handling for channel load failures. 2016-03-14 13:13:43 +01:00
Norbert Federa
ef4b29e5b3 ConvertFromUnicode fixes and misc hardening
- Added missing ConvertFromUnicode checks
- If ConvertToUnicode allocates memory, guarantee the null termination
  similar to ConvertFromUnicode's implementation
- Fixed some TestUnicodeConversion.c CTest return values
- Added some CTests for ConvertFromUnicode and ConvertToUnicode
- Misc code and protocol hardening fixes in the surrounding code regions
  that have been touched
2016-03-03 16:56:19 +01:00
Armin Novak
68c402ac58 Removed windows module.def files.
All symbols exported from libraries are declared
using *_API defines.
2016-02-29 15:18:47 +01:00
Bernhard Miklautz
6fa3608111 cleanup cmake exports and pkg-config files
With this commit the "exported" components (usable with pkg-config and
cmake find module package)
* winpr - winpr library and headers
* freerdp - core library and headers
* freerdp-client - client specific library
* freerdp-server - server specific library
* rdtk - rdtk headers and library

To allow the installation of multiple different version (different major
number) the include files were moved into the respective sub folder:
freerdp -> freerdp{MAJOR}/freerdp (currently freerdp2/freerdp/)
winpr -> winpr{MAJOR}/winpr (currently winrp1/winpr/)
rdtk -> rdpk{MAJOR}/rdtk (currently rdtk0/rdtk/

The generated pkg-config and cmake find modules now also include the major
version number. Currently the following pkg-config are generated and
installed.
* winpr1
* freerdp2
* freerdp-server2
* freerdp-client2
* rdtk0

As cmake is able to handle multiple versions out of the box the
following can be used to find a specific module:

find_package(WinPR)
find_package(FreeRDP)
find_package(FreeRDP-Server)
find_package(FreeRDP-Client)
find_package(RdTk)

As cmake doesn't automatically resolve dependencies for packages it is
necessary to manually include the requirements. For example if
FreeRDP-Client is required WinPR and FreeRDP need to be included
(find_package) as well.

This commit also fixes the installation when STATIC_CHANNELS are built.
WITH STATIC_CHANNELS all channels are linked into libfreerdp-client, for
this all channels are generated as linker archive and linked together in
the final step. Before the intermediate linker archives were, although
not required and useful, installed. Same applies for server side
channels.
2016-01-12 17:32:33 +01:00
Armin Novak
cb958ba9c6 Added pdb files to package target.
Fixed name collision with freerdp-shadow targets.
2015-12-15 12:07:21 +01:00
Hardening
70b9e994e1 Merge pull request #2941 from akallabeth/clipboard_file_fix
Clipboard file fixes
2015-12-10 16:13:24 +01:00
Martin Fleisz
6890e0b84d cliprdr/server: Fix incorrect message flags 2015-11-19 16:29:57 +01:00
Martin Fleisz
fc2768f807 cliprdr/server: Fix incorrect message header 2015-11-19 16:17:36 +01:00
Martin Fleisz
3070cab0fa cliprdr/server: Fix parsing of file contents request PDU 2015-11-19 14:12:26 +01:00
Bernhard Miklautz
0cdb4f7924 Fix compiler warnings
gcc (Debian 4.9.2-10) 4.9.2

winpr/libwinpr/thread/argv.c: In function ‘CommandLineToArgvA’:
winpr/libwinpr/thread/argv.c:94:6: warning: unused variable ‘index’ [-Wunused-variable]
  int index;

winpr/libwinpr/file/test/TestFileGetStdHandle.c: In function ‘TestFileGetStdHandle’:
winpr/libwinpr/file/test/TestFileGetStdHandle.c:44:2: warning: implicit
	declaration of function ‘CloseHandle’ [-Wimplicit-function-declaration]
  CloseHandle(stdout);
    ^
libfreerdp/codec/test/TestFreeRDPRegion.c: In function ‘test_norbert2_case’:
libfreerdp/codec/test/TestFreeRDPRegion.c:697:6: warning: unused variable ‘i’ [-Wunused-variable]
  int i;

channels/cliprdr/server/cliprdr_main.c: In function ‘cliprdr_server_receive_format_list’:
channels/cliprdr/server/cliprdr_main.c:636:24: warning: unused variable ‘cliprdr’ [-Wunused-variable]
  CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
                        ^
channels/cliprdr/server/cliprdr_main.c: In function ‘cliprdr_server_init’:
channels/cliprdr/server/cliprdr_main.c:1097:24: warning: unused variable ‘cliprdr’ [-Wunused-variable]
  CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
2015-11-09 19:26:34 +01:00
Martin Fleisz
25b1e39460 cliprdr/server: Server-side file content receiving used wrong callback 2015-10-29 12:45:12 +01:00
Martin Fleisz
730f43a380 cliprdr/server: Provide the server with a possibility to configure capabilities 2015-10-27 17:12:33 +01:00
Armin Novak
17a2d1ba1c Fixed clipboard file contents response and message to string. 2015-10-27 10:44:31 +01:00
Martin Fleisz
2d99f76667 cliprdr/server: Fix memory leak 2015-10-23 08:49:24 +02:00
Martin Fleisz
26d102c6dc cliprdr/server: Don't call CloseHandle on EventHandle 2015-10-16 11:40:25 +02:00