Commit Graph

2634 Commits

Author SHA1 Message Date
Armin Novak
bfeac80ed3 Fixed macro _stream_read_n16_le and _stream_read_n16_be
Cast to appropriate type to avoid integer truncation warnings.
2018-09-14 10:08:38 +02:00
Armin Novak
fad20be6e6 Fixed missing includes. 2018-08-27 14:34:42 +02:00
Armin Novak
00a5d06fc1 Fixed coverity memory leak. 2018-08-27 14:34:42 +02:00
Armin Novak
62c1696d4c Removed use of unchecked sprintf 2018-08-27 14:34:42 +02:00
Armin Novak
114abad767 Removed use of strcpy. 2018-08-27 14:34:09 +02:00
Armin Novak
d7d5567891 Fixed missing const. 2018-08-24 13:40:36 +02:00
Armin Novak
c159b2e9c8 Fixed missing check before calling memcpy 2018-08-24 13:40:36 +02:00
Martin Fleisz
8248dcb3bb
Merge pull request #4816 from akallabeth/drive_cmd_fix
Fix #4680: Return proper directory name.
2018-08-24 09:45:26 +02:00
Martin Fleisz
0afba58405
Merge pull request #4814 from akallabeth/linked_list_add_object
Linked list add object for user defined functions
2018-08-24 08:37:41 +02:00
Armin Novak
ab18f8f222 Fix #4680: Return proper directory name. 2018-08-23 10:04:26 +02:00
Ondrej Holy
95a043e0eb winpr/winsock: Fix leak found by covscan
0 is valid return value from socket().

leaked_handle: Handle variable "fd" going out of scope leaks the handle.
2018-08-23 09:11:24 +02:00
Ondrej Holy
0a11a06dc9 winpr/winsock: Format code by astyle
Run ./scripts/format_code.sh before the following changes.
2018-08-23 09:11:24 +02:00
Ondrej Holy
10b9c516f6 winpr/utils/wlog: Fix leak found by covscan
leaked_storage: Variable "result" going out of scope leaks the storage it points to.
leaked_storage: Variable "bt" going out of scope leaks the storage it points to.
2018-08-23 09:11:24 +02:00
Ondrej Holy
d3c2ceb0f6 winpr/utils/wlog: Format code by astyle
Run ./scripts/format_code.sh before the following changes.
2018-08-23 09:11:24 +02:00
Ondrej Holy
4813a70897 winpr/utils/ntlm: Prevent releasing function argument
The patch changes API of functions instead of fixing unused and broken code.

freed_arg: "free" frees parameter "NtHash".
2018-08-23 09:11:24 +02:00
Ondrej Holy
1c1d00aac0 winpr/utils/ntlm: Format code by astyle
Run ./scripts/format_code.sh before the following changes.
2018-08-22 14:34:02 +02:00
Ondrej Holy
35bccd5262 winpr/sspi/ntlm: Fix leak found by covscan
leaked_storage: Variable "sam" going out of scope leaks the storage it points to.
leaked_storage: Variable "s" going out of scope leaks the storage it points to.
leaked_storage: Variable "snt" going out of scope leaks the storage it points to.
2018-08-22 14:34:02 +02:00
Ondrej Holy
724bc7acd2 winpr/io/device: Fix leak found by covscan
leaked_storage: Variable "lpPipePath" going out of scope leaks the storage it points to.
2018-08-22 14:34:02 +02:00
Ondrej Holy
df9d0fab80 winpr/io/device: Format code by astyle
Run ./scripts/format_code.sh before the following changes.
2018-08-22 14:34:02 +02:00
Ondrej Holy
acbd6e6322 winpr/file: Fix leak found by covscan
overwrite_var: Overwriting handle "h" in "h = (HANDLE)0xffffffffffffffff" leaks the handle.
2018-08-22 14:34:02 +02:00
Armin Novak
b77dc13b5f Implemented linked list compare and value copy functions. 2018-08-22 12:39:11 +02:00
Armin Novak
8b8e85271c Fixed #4793: Return correct file handle for existing directory 2018-08-13 13:17:56 +02:00
Armin Novak
0352dc3d6c Fixed invalid format string. 2018-08-01 12:56:18 +02:00
Armin Novak
ed89328349 Fixed missing argument checks. 2018-07-30 10:46:20 +02:00
Armin Novak
3d8dec7fbf Removed debug log messages. 2018-07-11 16:37:29 +02:00
Armin Novak
dbfa896d5a Fixed errno reset. 2018-07-11 16:27:14 +02:00
Armin Novak
2b91095eb3 Fixed pattern detection if path is already a directory. 2018-07-11 10:58:37 +02:00
Armin Novak
30843ef4d8 Code cleanups and more logging. 2018-07-11 10:53:26 +02:00
Pascal J. Bourguignon
17a3782d1a FIX: moved declarations above the statements for strict C 90 compliance. 2018-06-07 13:29:44 +02:00
Pascal J. Bourguignon
15f2bafeab Cleaned up const char** -> char** for argv, since we definitely do modify the argv!
(we overwrite the password and pin arguments).
This implies changes in the argument parsing tests that now must pass a mutable argv
(copied from the statically declared test argvs).
Some other const inconsistency have been dealt with too.
2018-06-06 16:43:09 +02:00
Robert Corrigan
992554a01f Update time zone data to April 2018 2018-05-15 15:53:36 -04:00
Armin Novak
5a5b5eb6dd Fixed loadepng memory leak. 2018-05-15 14:30:35 +02:00
Martin Fleisz
f653686958
Merge pull request #4637 from akallabeth/win_ninja_support
VS2017 support: set pdb output directory for Ninja generator.
2018-05-15 13:47:28 +02:00
Armin Novak
e8b9116507 Fixed invalid function argument for ntlm_compute_message_integrity_check 2018-05-11 11:00:46 +02:00
Armin Novak
e71a39f214 Fixed compiler warnings (unused) 2018-05-11 11:00:01 +02:00
Armin Novak
6e958e7edb Fix #4628: CommandLineFindNextArgumentA must check the current argument
When determining if there is a next argument first check the current one
for abort criteria.
2018-05-06 10:49:05 +02:00
Armin Novak
5b961e9c75 Fixed /pth: Consistently treat the hash offset to password length. 2018-05-03 17:51:11 +02:00
akallabeth
dd577377dd
Merge pull request #4617 from kevans91/spurious
Upstream the rest of our local FreeBSD patching
2018-05-03 11:55:03 +02:00
akallabeth
d130d9cb21
Merge pull request #4613 from kevans91/file64
Enable 64-bit file support on FreeBSD as well
2018-05-03 11:31:54 +02:00
akallabeth
ba37f04e1b
Merge pull request #4616 from kevans91/timerfd-nonblock
Pass TFD_NONBLOCK to timerfd_create to avoid later fcntl
2018-05-03 10:56:04 +02:00
akallabeth
613e0be208
Merge pull request #4614 from kevans91/cmakemod
Abstract away CMake module installation setting, install differently on FreeBSD
2018-05-03 09:49:31 +02:00
Kyle Evans
8073a7850e Pull in the libepoll-shim includes for libwinpr's synch/test
This allows FreeBSD to successfully build with BUILD_TESTING enabled. Currently,
only 3/184 tests fail:

	 13 - TestLibraryLoadLibrary (Failed)
	 14 - TestLibraryGetProcAddress (Failed)
	 15 - TestLibraryGetModuleFileName (Failed)

These failures are probably due to a lack of GetModuleFileNameA implementation
on FreeBSD.
2018-05-02 23:19:44 -05:00
Kyle Evans
2fb992a962 Upstream the rest of our local FreeBSD patching
FreeBSD/DragonflyBSD are also UNIX platforms, as far as trio is concerned, and
we don't need to be setting the CMAKE_INSTALL_RPATH on FreeBSD.
2018-05-02 22:09:42 -05:00
Kyle Evans
f1a7c3cc6a Pass TFD_NONBLOCK to timerfd_create to avoid later fcntl 2018-05-02 21:03:49 -05:00
Kyle Evans
5463b23591 Enable 64-bit file support on FreeBSD as well 2018-05-02 10:38:44 -05:00
Kyle Evans
a7c0632bf2 Use SetFreeRDPCMakeInstallDir where CMake modules are installed 2018-05-02 10:36:52 -05:00
Armin Novak
60bf33f79d Determine posix timer availability by function availability
To avoid having to whitelist every os starting to implement posix
timer API just detect if the functions are available.
2018-05-02 11:17:32 +02:00
David Fort
a03c0d88d5
Merge pull request #4606 from kevans91/libressl-fixes
Pull in the LibreSSL compatibility patches from FreeBSD
2018-05-02 10:39:22 +02:00
Martin Fleisz
c0804699f1
Merge pull request #4609 from akallabeth/clipboard_return_check
Added proper return value checks for clipboard data.
2018-05-02 10:10:55 +02:00
Armin Novak
a1c3c1ad64 Added proper return value checks for clipboard data. 2018-05-02 09:21:42 +02:00
Kyle Evans
45d8e2dfb2 Pull in libepoll-shim for the bits that require timerfd/epoll
libepoll-shim is our implementation of this API on top of kevent. It supplies
the same headers and a library, but we don't install it in any of the default
include search paths when it comes in through ports on an as-needed basis.

This set of changes is restricted to FREEBSD-compatible OS, which includes
DragonflyBSD and FreeBSD.
2018-05-01 23:42:25 -05:00
Kyle Evans
f8c391876f Pull in the LibreSSL compatibility patches from FreeBSD 2018-05-01 08:43:36 -05:00
Martin Fleisz
b228deb998
Merge pull request #4543 from oshogbo/master
Fix variable passsed to HashCallback with MIC.
2018-04-18 14:50:31 +02:00
Mariusz Zaborski
509afe252d Remove MessageIntegrityCheck from context. 2018-04-17 15:03:27 +02:00
Mariusz Zaborski
fe37fede50 Fix variable passsed to HashCallback with MIC.
The value in the context is not set yet and we need one from
authentication message.
2018-04-06 21:18:20 +02:00
Mariusz Zaborski
00374382d9 There is no reason to restrict nSize to 2 the hostname can be empty on
UNIX-like machines.
2018-04-06 21:07:51 +02:00
MartinHaimberger
a9ecd6a6cc
Merge pull request #4535 from akallabeth/warning_fixes
Warning fixes
2018-04-05 10:20:43 +02:00
MartinHaimberger
55973288f2
Merge pull request #4514 from akallabeth/com_lpt_fix
Com lpt fix
2018-04-04 12:52:39 +02:00
Armin Novak
842707b106 Fixed printf format string. 2018-04-04 10:44:51 +02:00
Armin Novak
b260937ca6 Use __attribute__((destructor)) on non windows systems.
atexit in shared libraries is not universally supported.
2018-04-03 14:04:22 +02:00
Armin Novak
e0d112d548 Removed all calls to WLog_Init and WLog_Uninit
Since the calls are no longer required remove their usage.
2018-04-03 13:06:41 +02:00
Armin Novak
d249335708 Removed winpr_exit
As the cleanup functions are called by atexit a dedicated
cleanup call is no longer required.
2018-04-03 12:56:33 +02:00
Armin Novak
e1b53a282f Fix #4524: Initialize with cleanup handler
Use singleton initializer and register cleanup handler for logger.
2018-04-03 10:18:59 +02:00
UndefBehavior
08e7217c1b Fix SCardStatusW function
Terminating null character was inserted in the middle of readerNames instead of
last position in the unicode version of SCardStatus function.
This commit fix it.
2018-03-30 07:32:23 -07:00
Ilya Shipitsin
14c15c680d resolve several possible null pointer dereference
issue detected by cppcheck

[channels/drive/client/drive_main.c:454] -> [channels/drive/client/drive_main.c:443]: (warning) Either the condition '!irp' is redundant or there is possible null pointer dereference: irp.
[client/X11/xf_window.c:582] -> [client/X11/xf_window.c:580]: (warning) Either the condition '!xfc' is redundant or there is possible null pointer dereference: xfc.
[winpr/libwinpr/path/test/TestPathShell.c:40] -> [winpr/libwinpr/path/test/TestPathShell.c:43]: (warning) Either the condition '!path' is redundant or there is possible null pointer dereference: path.
[winpr/libwinpr/path/test/TestPathShell.c:49] -> [winpr/libwinpr/path/test/TestPathShell.c:52]: (warning) Either the condition '!path' is redundant or there is possible null pointer dereference: path.
2018-03-24 17:46:39 +05:00
Armin Novak
1316b828c9 Removed reserved COM and LPT check. 2018-03-23 10:44:32 +01:00
Martin Fleisz
8df96364f2 cssp: Add support for protocol version 6 2018-03-20 10:37:38 +01:00
Armin Novak
9bd13c25c9 Added WaitableTimer implementation for mac OS. 2018-03-12 13:39:21 +01:00
Armin Novak
44eebbb6e0 Fixed compiler warnings. 2018-03-07 14:47:06 +01:00
Armin Novak
66cc038c93 Fixed threadpool work function return and arguments. 2018-03-07 14:36:55 +01:00
Armin Novak
2517755d25 Fixed thread function return and parameters. 2018-03-07 14:36:55 +01:00
Martin Fleisz
900aa94796 debug: Fix broken format specifiers 2018-03-06 16:32:36 +01:00
Martin Fleisz
5077e88689
Merge pull request #4447 from akallabeth/apple_rpath_namespace
Apple rpath namespace fixes
2018-02-16 10:54:03 +01:00
Armin Novak
10aabdd631 Removed apple flat-namespace hack. 2018-02-16 10:05:11 +01:00
Armin Novak
e36d87b55c Fix #4445: Do not call fclose on NULL file. 2018-02-16 09:05:39 +01:00
Martin Fleisz
5d1ff02d02
Merge pull request #4414 from akallabeth/pthread_cleanup_fix
Pthread cleanup fix
2018-02-15 11:02:37 +01:00
Martin Fleisz
19a00f2099
Merge pull request #4325 from akallabeth/fixes_com
Fixes serial redirection name check and SAM file parser
2018-02-15 10:39:33 +01:00
Martin Fleisz
13be71381c
Merge pull request #4434 from akallabeth/winpr_digest_param
Fixed winpr digest type.
2018-02-14 15:54:13 +01:00
Armin Novak
89859d4c54 Fixed missing error return. 2018-02-14 13:51:38 +01:00
Armin Novak
5903d5b375 Fixed winpr digest type. 2018-02-14 12:48:45 +01:00
Armin Novak
53d2150e00 Fixed windows unicode authentication. 2018-02-13 11:29:56 +01:00
Armin Novak
2d58e96dcc Exit main thread with winpr_exit to trigger resource cleanup.
When using pthread_once with destructors they are only called,
if each thread (including the main thread) is exited with pthread_exit.
Introducing winpr_exit as a wrapper for that purpose.
2018-02-12 10:33:02 +01:00
Armin Novak
855dc9abaf Clear message queue on free. 2018-02-09 10:29:18 +01:00
Armin Novak
c586a300cf Fixed init once return. 2018-02-07 13:22:07 +01:00
Bernhard Miklautz
c7f1656ea8
Merge pull request #4400 from hardening/defines_clean
set some define consistency
2018-02-07 12:34:27 +01:00
David Fort
7ceb85c7a8
Merge pull request #4340 from akallabeth/init_once
Fix remaining issues with #2006
2018-02-07 10:34:18 +01:00
David Fort
6c64aa4e20 fixed include path
It was working because of multiple include directories.
2018-02-05 14:34:49 +01:00
David Fort
917bc4b551 set some define consistency
This patch cleanup the defines to make then consistent.
2018-02-05 14:17:23 +01:00
Armin Novak
60ab8cc724 Fixed memory leak. 2018-01-24 14:11:33 +01:00
Armin Novak
29f2d2d9bb Fixed missing packageName setup in server NLA 2018-01-17 09:09:58 +01:00
Armin Novak
dc48c42926 Refactored NTLM, functions static where approprate 2018-01-16 11:34:07 +01:00
Armin Novak
1611ec16b1 Refactored kerberos SSPI
* Functions static where approrpriate
* Variables static const where appropriate
2018-01-16 10:58:30 +01:00
Armin Novak
609a4eb6ae Fixed ICU support for CP_ACP 2018-01-16 10:37:19 +01:00
Armin Novak
c62fde53a4 Fix #4306:
* Do not reset context when changing package.
* All functions not exported static.
2018-01-16 10:31:08 +01:00
Armin Novak
5550f6ffe1 Fixed #4357: NTLM debug message. 2018-01-12 09:22:08 +01:00
Armin Novak
9804d5a4a7 SamOpen return NULL if file was not opened. 2018-01-08 13:07:11 +01:00
Armin Novak
d03f9858af Fixed #2006: Use InitOnceExecuteOnce 2018-01-08 12:41:32 +01:00
David Fort
e1cc601963
Merge pull request #4323 from akallabeth/scanbuild_fixes
Scanbuild and other warnings fixed
2018-01-08 11:16:21 +01:00
Anton Afanasyev
ed2e4e576d StartHTML and EndHTML values can be left-padded with 0 characters. strtol and friends treat this as base-8 if base is specified as 0.
Because these values are always sent in base-10, fix is to always use base-10
2018-01-06 18:45:22 -08:00
Armin Novak
04708b37e1 Fixed serious issues with SAM file parser
The parser ommitted various checks during file parsing.
Invalid syntax did crash the whole thing.
2017-12-21 14:39:43 +01:00
Armin Novak
6f1b8f04c6 Fixed check for reserved com devices. 2017-12-21 14:39:32 +01:00
Armin Novak
a0b49f4e07 Removed unused functions, fixed feature define guards 2017-12-21 11:30:21 +01:00
Armin Novak
50a0968c6a Removed unused variables. 2017-12-21 11:29:24 +01:00
Armin Novak
6a21bdae3d Fixed various scanbuild warnings. 2017-12-21 09:34:35 +01:00
akallabeth
e3e65734e8
Merge pull request #4303 from krisztian-kovacs-balabit/use-redirection-password
Use redirection password
2017-12-20 17:01:58 +01:00
Martin Fleisz
bfe8359b5b
Merge pull request #4239 from akallabeth/test_memleak_fixes
Test memleak fixes
2017-12-20 12:38:38 +01:00
akallabeth
097f8edd97
Merge pull request #4312 from bmiklautz/smartcard-cleanup
Smartcard fixes and cleanup
2017-12-14 16:56:29 +01:00
Bernhard Miklautz
5a1c0081c5 fix smartcard: SCardStatus unicode handling
* fix StatusW_Call to rely and use SCardStatusW
* fix trace call in  StatusW_Call - needs to be called after the sizes
  are set
* unify SCardStatus functions for pcsc - let the internal function handle unicode directly

This fixes an issue with size calculations of SCardStatusW.
2017-12-14 15:46:14 +01:00
Martin Fleisz
5cec90c781
Merge pull request #4305 from hardening/xrandr_fix
Fix XRandr for old systems and MacOSX
2017-12-13 17:24:41 +01:00
Bernhard Miklautz
bff9b98e67 feat winpr/smartcard: add test for SCardStatus
Add an extensive test for SCardStatus. It's not enabled per default
as it requires a reader with card to be present.
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
6b691948cf refactor winpr/smartcard/pcsc: reader/group naming
The PCSC SCard implementation in winpr tried to rename reader and group
names received from PCSC to something similar to what the windows smart
card service would return.

Because of the following reasons this mapping was removed:

* reader names are not standardized
* no mapping of reader name should be required at all
* the mapping added extra complexity
* the mapping didn't produce the same names as if the reader was
  directly connected on windows (or redirected from a windows host)

In case there are situations where this is nevertheless required this
feature can simple be (re-)implemented a part of the smart card channel.

Also the formatting was fixed.
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
389b7f218b feat winpr: add WINPR_UNUSED macro
WINPR_UNUSED can be used to mark intentionally unused function parameters.
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
e3d45c4580 fix channel/smartcard: remove SCardAddReaderName
SCardAddReaderName isn't part of the SCard API.

Note: removing this also removes the possibility to redirect single
smartcard readers with /smartcard:READERNAME. However this features
wasn't implemented in a general way and will be re-added as part of
the smart card channel directly.
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
6e63c6afd9 fix channel/smartcard: remove status mappings
The state tracking/modifications (presumably thought as optimization?!) in
PCSC_SCardGetStatusChange_Internal cause a lot of applications to behave
incorrectly and/or hang. Ideally no modifications of the states should
be necessary as PCSC implements the same API as passed over the channel.
2017-12-13 17:04:06 +01:00
Martin Fleisz
f6b8a6eaa2
Merge pull request #4276 from akallabeth/big_endian_more
Big endian fixes
2017-12-13 09:58:14 +01:00
Armin Novak
ae2a96293b Cleanup and initialization checks. 2017-12-12 11:40:48 +01:00
Armin Novak
7305828122 Fix #4239: Various memory leaks
* Fixed all tests, now can be run with -DWITH_ADDRESS_SANITIZER=ON compiled.
* Enabled address sanitizer for nightly builds.
2017-12-12 11:40:48 +01:00
Armin Novak
0a9ef97a57 Fixed uninitialized variable. 2017-12-12 10:35:02 +01:00
David Fort
41823080f9 Fix users of Stream_GetPosition() that returns size_t 2017-12-11 22:38:58 +01:00
KOVACS Krisztian
3c56300afa winpr/sspi: add possibility to set auth identity with Unicode password
To be able to avoid password conversion if the password is already unicode
this change adds the sspi_SetAuthIdentityWithUnicodePassword() function
that is identical to sspi_SetAuthIdentity() except that the password is
used without further conversions in the Unicode identity.
2017-12-06 16:30:57 +01:00
Martin Fleisz
876a7697be
Merge pull request #4297 from akallabeth/cmd_parser_hardening
Fix #4296: Hardened command line post filter.
2017-12-05 14:40:03 +01:00
Greg V
bfe3af4c72 Fix LibreSSL build
LibreSSL does not support FIPS mode.
2017-12-01 18:34:48 +03:00
Armin Novak
78a0c4c618 Fix #4296: Hardened command line post filter. 2017-12-01 13:13:21 +01:00
akallabeth
0cb5907664
Merge pull request #4275 from ondrejholy/big-endian-fixes
Big endian fixes
2017-12-01 11:24:50 +01:00
akallabeth
ae0fb64656
Merge pull request #4283 from bmiklautz/kfreebsd
fix build: GNU/kFreeBSD
2017-11-28 09:19:58 +01:00
David Fort
2f4a2f8595
Merge pull request #4272 from akallabeth/static_channel_checks
Fix #3378: 31 static channels are supported.
2017-11-27 22:46:23 +01:00
Bernhard Miklautz
0da2fb6915 fix/build: handle GNU/kFreeBSD like other BSDs
Based on a patch for Debian from
Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
2017-11-27 17:04:52 +01:00
Mike Gabriel
d4af7eaa59 fix/build: GNU/kFreeBSD is not FreeBSD 2017-11-27 17:04:52 +01:00
Bernhard Miklautz
50105c8157
Merge pull request #3991 from akallabeth/stream_string_helper
Stream convenience functions to read/write strings.
2017-11-27 11:49:46 +01:00
Armin Novak
c91900dfb3 Fixed big endian issues with bitmap read. 2017-11-24 12:03:46 +01:00
Ondrej Holy
e5574f276a winpr/nt: Fix wide char string on big endian
Wide char strings are always little endian encoded and thus
Data_Write_UINT16 has to be used in _RtlAnsiStringToUnicodeString.
It fixes TestIoDevice on big endian machines among others.

https://github.com/FreeRDP/FreeRDP/issues/4231
2017-11-23 20:01:01 +01:00
Armin Novak
377bfeb227 Fix #3378: 31 static channels are supported. 2017-11-23 16:18:44 +01:00
akallabeth
71e38a4ce7
Merge pull request #4267 from ondrejholy/autofips
Enable FIPS mode automatically
2017-11-23 10:49:15 +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
Armin Novak
4fe12b0ea3 Fix #4247: warnings introduced with #3904 2017-11-20 10:18:15 +01:00
akallabeth
b156b937fe
Merge pull request #3904 from bjcollins/master
FIPS Mode support for xfreerdp
2017-11-17 13:31:43 +01:00
Martin Fleisz
4ff1251488
Merge pull request #4236 from akallabeth/scan_fix_remastered
Scanbuild warning fixes
2017-11-17 13:02:46 +01:00
Armin Novak
1bb4f121b4 Fixed formatting. 2017-11-17 12:45:28 +01:00
Brent Collins
9ca9df1ead Make the new winpr_Digest*MD5_Allow_FIPS functions more generic to no longer be MD5 specific in design. This way the FIPS override
could easily be extended to more digests in the future. For now, an attempt to use these functions with anything other than MD5 will
not work.
2017-11-17 12:43:07 +01:00
Brent Collins
922a0fa495 Fix checks for openssl version numbers around fips changes, they were using an incorrect version matching 1.1.0 and not 1.0.1
Simplify the logic to enable openssl fips mode
2017-11-17 12:43:07 +01:00
Brent Collins
a0526317ea Fix the return values of the winpr_Digest_Init functions which were accidentally removed
during rework in previous checkin.
2017-11-17 12:43:07 +01:00
Brent Collins
68ab485e63 Fix logic error in reworked MD5 call for establishing keys, and fix some minor whitespace issues. 2017-11-17 12:43:07 +01:00
Brent Collins
7aa9e7a97f Fix variable definition placement to adhere to older C standard. 2017-11-17 12:43:06 +01:00
Brent Collins
5284100bb0 FIPS_mode() and FIPS_mode_set() does not exist in OpenSSL versions before 1.0.1 2017-11-17 12:43:06 +01:00
Brent Collins
2dddae738f Change initialization of EVP_CIPHER_CTX to use API function instead of trying to calloc().
Fix some warnings noted from build output.
2017-11-17 12:43:06 +01:00
Brent Collins
497ba442be Workaround for missing EVP_CIPH_FLAG_FIPS_NON_ALLOW flag in openssl 1.0.0. 2017-11-17 12:43:06 +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
David Fort
0d92c725c6
Merge pull request #4000 from akallabeth/ign_keyword_fix
Command line ignore empty if flag set
2017-11-16 13:26:01 +01:00
Armin Novak
7b58495e7b Fixed warnings and formatting. 2017-11-15 15:56:24 +01:00
Armin Novak
1fd6308ef5 Functions static, warnings fixed. 2017-11-15 15:56:24 +01:00
Armin Novak
90e1d39fec Fixed formatting and warnings. 2017-11-15 15:56:24 +01:00
Armin Novak
44dfaf7841 Fixed dead store warning. 2017-11-15 15:56:24 +01:00
Armin Novak
3baba6f9c0 Removed unused argument. 2017-11-15 15:56:24 +01:00
Armin Novak
f24158fe07 Fixed missing function return check. 2017-11-15 15:56:24 +01:00
Armin Novak
0aa5a83536 Fixed multiple warnings in parser 2017-11-15 15:56:21 +01:00
Armin Novak
26d079e53b Fixed compile warnings. 2017-11-15 15:54:38 +01:00
Armin Novak
4eb5b8e349 Replaced atoi 2017-11-15 15:52:16 +01:00
Armin Novak
8c2bd951ae Allow printing of custom arguments in help. 2017-11-15 15:25:34 +01:00
Armin Novak
65f4c560d3 Fixed uninitialized values and leaks. 2017-11-13 16:20:57 +01:00
dodo040
60406794ce fix Kerberos flavour's detection (MIT/Heimdal) and double free for MIT<1.13 2017-11-13 16:20:56 +01:00
dodo040
1d97286a76 fix undeclared identifier on Windows 2017-11-13 16:20:56 +01:00
dodo040
335de159b0 use SSIZE_T instead of ssize_t 2017-11-13 16:20:56 +01:00
dodo040
9adb971181 handle missing ssize_t on Windows 2017-11-13 16:20:56 +01:00
dodo040
3e897a63cb remove useless includes 2017-11-13 16:20:56 +01:00
dodo040
e0a9999fb2 fix: GSS API init, enterprise name management, variable names and format code 2017-11-13 16:20:56 +01:00
dodo040
b81f168f0e initial commit for kerberos support 2017-11-13 16:20:55 +01:00
David Fort
de7d7e43c9 serial redirection: implement event char
The signotec signature device requires the eventChar support to work properly in
serial redirection mode. This implementation is basic but does the job for this
device.

Sponsored by: Rangee GmbH (http://www.rangee.de)
2017-11-06 22:26:17 +01:00
Armin Novak
269c78802d Fixed #4199: ConvertFindDataAToW string length 2017-10-31 16:52:08 +01:00
Mike Gilbert
5cd230ac74 winpr: _IoCreateDeviceEx: fix mkdir error check
The mkdir(2) function returns 0 on success, and -1 on error.

This resolves an error in TestIoDevice when /tmp/.device/ does not
exist.

Bug: https://bugs.gentoo.org/635838
2017-10-30 11:59:35 -04:00
Roman Kalashnikov
612e8b0710
Update semaphore.c 2017-10-28 11:59:23 +03:00
Roman Kalashnikov
4db363f107
Fixed Expression 'pComm != NULL' is always true
pComm was checked earlier in 1363 string:
`if (pComm == NULL)`
2017-10-28 01:48:41 +03:00
Roman Kalashnikov
67a97612e6
Fixed duplicated assigne 2017-10-28 01:46:06 +03:00
Armin Novak
3840b27945 Fixed file timestamps. 2017-10-12 11:28:07 +02:00
Bernhard Miklautz
1aec784f75 feat: add support for .source_version
When building packages, especially when source packages are used, git is
not necessarily available or the source isn't provided in git. In those
cases it wasn't possible to set the GIT_REVISION and --version shows
"n/a" for the git revision.

If the file .source_version is available now the content of it is used
as GIT_REVISION. Packagers might want to add a .source_version file
when they don't build the packages from git.

Possible breaking change:

The variable PRODUCT_VERSION isn't available anymore. Use GIT_REVISION
instead.
2017-10-06 15:02:23 +02:00
Armin Novak
bcfa434da2 Fixed resizing of PubSub 2017-09-25 13:33:04 +02:00
David Fort
babeb34d88 Merge pull request #4060 from akallabeth/icu_support
Using ICU instead of custom unicode conversion.
2017-09-25 09:33:58 +02:00
Bernhard Miklautz
3626676ac6 winpr/makecert: fix linking against libcrypto
Use OPENSSL_CRYPTO_LIBRARIES instead of linking against crypto directly.
2017-09-23 14:13:39 +02:00
Bernhard Miklautz
bbd11eef1d Merge pull request #4045 from akallabeth/drive_fixes_overlayfs
Drive fixes overlayfs
2017-09-22 17:22:00 +02:00
David Fort
5115ecd948 Merge pull request #4063 from akallabeth/auth_fixes
Fixed leaks, certificate comparison and channel context cleanup
2017-08-30 10:19:12 +02:00
Bernhard Miklautz
52fbfb7b12 fix clang warnings, directly include wtypes.h (#4097)
* build: clang use -Wno-unused-command-line-argument

With clang 5.0 builds are quite noisy otherwise.

* Directly include wtypes.h

Directly include winpr/wtypes.h where _fseeki64 or _ftelli64 is used.

* fix build warnings with clang 5

clang version: 5.0.0-svn310678-1~exp1 (branches/release_50)
Warning: parentheses-equality

* fix build warnings with clang 5

clang version: 5.0.0-svn310678-1~exp1 (branches/release_50)
Warning: tautological-compare

* fix build warnings with clang 5

clang version: 5.0.0-svn310678-1~exp1 (branches/release_50)
Warning:
incompatible pointer types passing 'size_t *' (aka 'unsigned
long *') to parameter of type 'UINT32 *' (aka 'unsigned int *')
[-Wincompatible-pointer-types]
2017-08-29 09:09:38 +02:00
Armin Novak
7e32e90d4c Fixed RSA generation for OpenSSL >= 1.1 2017-08-17 13:16:32 +02:00
Armin Novak
f143fcc298 Fixed data type, eliminate warning. 2017-08-16 15:45:11 +02:00
Armin Novak
9ebfbc1fcb FindNextFileAx, continue if a inalid file is found. 2017-08-16 10:25:23 +02:00
Bernhard Miklautz
ed36f55f3e Merge pull request #4088 from akallabeth/file_api_64bit_fixes
fseeko and ftello for 64bit file support.
2017-08-16 10:04:13 +02:00
Armin Novak
c3d4b7d262 fseeko and ftello for 64bit file support. 2017-08-14 08:42:49 +02:00
Armin Novak
82d9ebc380 Fixed FileSetFilePointer warnings 2017-08-10 16:56:20 +02:00
MartinHaimberger
80ed23779f Merge pull request #4076 from akallabeth/SetFilePointer_fix
Set file pointer fix
2017-08-09 10:35:37 +02:00
Armin Novak
7d7e5487ab Fixed SetFilePointer, added SetFilePointerEx 2017-08-08 10:51:50 +02:00
Jura Sasek
a84c5cbfb9 Sun keyboard 2017-08-04 13:09:32 +02:00
Armin Novak
efe6971899 Skip FIFO files in listings. 2017-08-04 09:01:13 +02:00
Armin Novak
0a23bdf61f Abort CreateFile for existing files of type FIFO 2017-08-03 14:45:19 +02:00
Armin Novak
436829142e Mapped ENOTCONN to ERROR_FILE_NOT_FOUND 2017-08-03 14:38:20 +02:00
Mike Gabriel
dc075fb133 Fix warning in man pages
"warning: can't find macro file `www.tmac))'""`"
2017-08-03 08:41:50 +02:00
Mike Gabriel
c045bddf3f Fix typos in some error messages 2017-08-03 08:38:05 +02:00
David Fort
c84065f40c Merge pull request #4069 from yurashek/master
Build on Solaris
2017-08-02 09:53:38 +02:00
Armin Novak
11fa9f6753 Free credentials on exit. 2017-07-28 08:39:49 +02:00
Armin Novak
ceda244165 Fixed uninitialized values and leaks. 2017-07-28 08:35:31 +02:00
Valery Kartel
9bf9ff9e8a Fix build with LibreSSL 2017-07-26 17:12:14 +03:00
Armin Novak
1868acb0ac Using ICU instead of custom unicode conversion.
If WITH_ICU CMake option is set the unicode conversion routines
use ICU instead of custom conversion code.
2017-07-26 13:00:45 +02:00
Armin Novak
c8f97efb40 Added EROFS mapping. 2017-07-26 11:02:55 +02:00
Armin Novak
2beaf2c612 Added error message in case of unmapped ERRNO value. 2017-07-24 15:08:44 +02:00
Armin Novak
d1ebc39b07 Fixed file errno mapping. 2017-07-24 15:05:48 +02:00
Armin Novak
06f6c0f8cb Removed STANDARD_RIGHTS_WRITE from writeable check. 2017-07-24 11:31:48 +02:00
Armin Novak
41f919b8bd Fixed integer size warnings. 2017-07-24 11:31:48 +02:00
Armin Novak
2d18267538 Stream convenience functions to read/write strings. 2017-07-24 08:58:15 +02:00
Bernhard Miklautz
f23e10f64b clipboard: fix possible invalid memory access
Fix an possible issue found by Sébastien Duquette.
2017-07-20 09:35:42 +02:00
Armin Novak
0490aeb018 Fixed clang malloc integer overflow warnings. 2017-07-20 09:29:48 +02:00
dodo040
2f22e679e0 fix format code 2017-07-19 13:16:08 +02:00
dodo040
4e055453ab fix smartcard argument parsing 2017-07-19 13:16:08 +02:00
dodo040
722e927c64 redirect specific smartcard readers 2017-07-19 13:16:08 +02:00
akallabeth
f0fb219580 Merge pull request #4041 from wayk/PathMakePathA
Fixed PathMakePathA (returned true even if it can't create the last f…
2017-07-17 12:26:48 +02:00
Robert Corrigan
005c4df9b0 Update time zone data to July 2017 2017-07-14 17:16:08 -04:00
François Dubois
2a1fde25c8 Fixed PathMakePathA (returned true even if it can't create the last folder of the path) 2017-07-12 14:47:08 -04:00
Norbert Federa
36b8f54c5e Fixed a few compiler warnings 2017-07-10 17:52:05 +02:00
Olivier Blin
d65c2a90ea Fix clipboard POSIX build because of basename conflict
FreeRDP/winpr/libwinpr/clipboard/posix.c:397:20: error: conflicting types for ‘basename’
 static const char* basename(const char* name)
                    ^
In file included from FreeRDP/winpr/include/winpr/collections.h:25:0,
                 from FreeRDP/winpr/libwinpr/clipboard/posix.c:37:
/usr/include/string.h:599:14: note: previous declaration of ‘basename’ was here
 extern char *basename (const char *__filename) __THROW __nonnull ((1));
2017-07-05 18:48:37 +02:00
weizhenwei
fa1c65b656 refactor to remove duplicate code and replace free+malloc with realloc 2017-06-22 10:21:20 +08:00
weizhenwei
64fce8717f fix memroy leak of fd at FindFirstFileW() 2017-06-21 15:26:28 +08:00
Armin Novak
33a153c07d Command line ignore empty if flag set
When CommandLineParseArgumentsA is called with flag
COMMAND_LINE_IGN_UNKNOWN_KEYWORD return success if the
command line is empty.
2017-06-12 12:23:10 +02:00
David Fort
5ef9232703 Merge pull request #3905 from ilammy/x11-cliprdr/file-clipping
Local-to-remote file clipping for xfreerdp
2017-06-07 21:20:34 +02:00
ilammy
987d7dd886 winpr/file: add missing NULL check
ValidFileNameComponent() has been missing a NULL check for its argument.
It's pretty obvious that NULL is not a valid file name component.
2017-05-24 23:19:39 +03:00
ilammy
a85cf1b749 wClipboard: drop WITH_DEBUG_WCLIPBOARD option
This preprocessor definition has been initially intended to disable some
computationally expensive logging, however it turned out that there is
not much computation involved in the resulting implementation of new
wClipboard subsystems. Therefore we do not actually need the compilation
option, the logs can be filtered by "com.winpr.wclipboard.*" tag at
runtime if necessary. So drop the WITH_DEBUG_WCLIPBOARD CMake option and
convert all detailed logs to use WLOG_TRACE level via WLog_VRB macro.
2017-05-24 23:17:33 +03:00
Jura Sasek
4edb5cf7e6 Build for Solaris 2017-05-24 04:27:01 -07:00
David Fort
48163a27db Merge pull request #3906 from akallabeth/addin_cast_fix
Addin cast fix
2017-05-22 11:12:05 +02:00
davewheel
4bfb4dddbf Add a callback to provide NTLM hashes on server-side
Adds a callback that allows servers to compute NTLM hashes by themselves. The typical
use of this callback is to provide a function that gives precomputed hash values.

Sponsored by: Wheel Systems (http://www.wheelsystems.com)
2017-05-18 14:24:24 +02:00
Armin Novak
620b1ea603 Added 64bit file support flag for linux. 2017-05-10 14:58:12 +02:00
Armin Novak
4ba7670e43 Fixed right shift on 32bit platforms. 2017-05-04 09:20:10 +02:00
David Fort
677c4e2105 Merge pull request #3919 from akallabeth/rdpdr_hotplug_fix
Fixed hotplug mount locations.
2017-04-27 14:11:51 +02:00
Armin Novak
d1e7ce9ce0 Fixed FindFirstFileA, do not strip trailing slash 2017-04-27 08:59:21 +02:00
Armin Novak
dafa6cef67 Fixed memory corruption in Find*FileW 2017-04-27 08:31:53 +02: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
d341973247 winpr: include Windows headers in <winpr/shell.h>
This header file (currently) provides definitions of FILEDESCRIPTOR
structure and GetUserProfileDirectory() function. However, it does so
only when included on non-Windows platforms. The code which includes it
fails to build on Windows because the definitions are absent and it
causes weird compilation errors (like FILEDESCRIPTOR being treated as
the name of a function argument).

Inculde <shlobj.h> to get FILEDESCRIPTOR and <userenv.h> for the
GetUserProfileDirectory() function. (And hope that this will not
pull more Windows headers than we need in the files which include
<winpr/shell.h>.)
2017-04-21 00:44:46 +03:00
Armin Novak
920a76d57e Fix #3922: Use stat insead of lstat 2017-04-19 08:28:00 +02:00
Robert Corrigan
97c5494b98 Update timezone data to Apr 2017 2017-04-18 16:15:13 -04:00
Norbert Federa
736675aa01 Merge pull request #3901 from akallabeth/openssl_1_1_no_legacy
Fixed OpenSSL 1.1 no legacy compile issues.
2017-04-11 15:00:30 +02:00
Armin Novak
4e32334621 Added error return in GetFileAttributesExA. 2017-04-11 11:34:11 +02:00
Armin Novak
b0289e3ed8 Fixed cast warnings. 2017-04-10 10:39:01 +02:00
ilammy
44b04cafef wClipboard: disallow Windows reserved names
Another issue revealed during testing is that older Windows systems
cannot handle the reserved file names well. While Windows 8 and 10 are
fine (they silently abort the file transfer), using reserved names with
Windows 7 can flat out crash explorer.exe or result into weird error
messages like "fatal error: 0x00000000 ERROR_SUCCESS".

This is not required by MS-RDPECLIP specification, but we should try to
avoid this issue as not using reserved file names seems to be assumed
a common sense in Windows protocols.

The most convenient way to handle the issue would be on wClipboard level
so that WinPR's clients do not bother with it. We should prohibit the
reserved names from being used in FILEDESCRIPTOR, failing the conversion
if we see such a file.

POSIX subsystem (the only one at the moment) handles remote file names
in two places so move the Unicode conversion and the new validation
check into a separate function.

The reserved file name predicate is placed into <winpr/file.h> so that
it can be used in other places too. For example, other wClipboard local
file subsystems will need it. (It would be really nice to enforce this
check somewhere in the common code, so that the subsystems can't miss
it, but other places can miss some errors thus we're doing it here, as
early as possible.)

The predicate acts on separate file name components rather than full
file names because the backslash is a reserved character too. If we
process full file names this can result in phantom directory entry in
the remote file name. Not to say that handling ready-made components
spares us from splitting the full file name to extract them :)

The implementation is... a bit verbose, but that's fine by me. In the
absence of functions for case-insensitive wide string comparison and
the need to check for the [0-9] at the end of some file names this is
quite readable. Thanks to FAT and NTFS for being case-insensitive and
to MS-DOS for having reserved file names in the first place.
2017-04-09 03:17:07 +03:00
ilammy
458c042b53 wClipboard: track sequence numbers of file lists
One important point in the cliprdr protocol is that the peers are not
allowed to request file sizes and ranges if the clipboard content
changes. File locking should be used to gain this ability. However, our
file list is still accessible after new data is set into wClipboard.

Catch this error by storing the sequence number of the file list when it
is set and checking that it is still in effect at the time when the
client requests file sizes or ranges. There is a small chance of false
positives when the sequence number overflows, but I guess we can safely
ignore it.
2017-04-09 03:15:49 +03:00
ilammy
092e870d2a wClipboard/posix: implement file range retrieval
This is another bunch of callbacks which provide the file contents to
the clients. We jump through some extra hoops in order to have more
pleasant user experience.

Simple stuff goes first. The file offset (or position) is split into the
low and high parts because this is the format in which the clients
receive the request from the server. They can simply copy the values as
is into the struct without repackaging them (which we do instead in the
end to get a 64-bit off_t).

Another thing is that we try to minimize the number of lseek() calls and
to keep as few file descriptors open as possible. We cannot open all the
files at once as there could be thousands of them and we'll run out of
the allowed number of the fds. However, the server can (in theory)
request the file ranges randomly so we need to be prepared for that. One
way to do that would be to always open the file before reading and close
it immediately afterwards. A dead simple solution with an acceptable
performance, but... some file systems do not support seeking, such as
FTP directories mounted over FUSE. However, they handle sequential
reading just fine *and* the server requests the data sequentially most
of the time so we can exploit this.

Thus open the file only once, during the first range request and keep
it open until the server reads all the data. In order to know how much
data is left we keep an accurate account of all reads and maintain the
file offset ourselves. This also allows us to avoid calling lseek() when
the file offset will not be effectively changed. However, if the server
requests some weird offset then we have no choice and will attempt
seeking. Unfortunately, we cannot tell whether it is a genuine failure
or the file system just does not support seeking, so we do not handle
the error further. (One workaround would be to reopen the file and keep
reading it until we're at the correct offset.) In this way we can
support sequential-only file systems if the server requests the contents
sequentially (and it does).

Also note that we do an fstat() right after opening the file in order to
have an accurate value of file size, for this exact file descriptor we
will be using. We should have it filled it by now, but just in case...

There is one more thing to explain. The cbRequested field specifies the
maximum number of bytes the server can handle, not the required number.
Usually this is some power-of-two number like 64 KB, based on the size
of the files on the clipboard. This is why posix_file_read_perform()
does not attempt to fill the whole buffer by repeatedly calling read()
if it has read less data than requested. The server can handle underruns
just fine (and this spares us from special-casing the EOF condition).
2017-04-09 03:15:49 +03:00
ilammy
33719d24ce wClipboard/posix: implement file size retrieval
This is an example of wClipboardDelegate method implementation. POSIX
subsystem uses synchronous methods, but the interface can be used for
asynchronous request processing as well. The client should call a
Client* callback to request some action and the wClipboard will process
the request and report the result by calling an approriate Clipboard*
callback. Usually there will be two callbacks: one for reporting success
and one to report errors.

All callbacks have at least two arguments: the wClipboardDelegate itself
to pass the system context, and the wClipboard*Request structure with
the arguments to pass the call context. The request context is also
passed to the result callbacks by wClipboard so that the client can
match up the result with its previous request.

The fields of wClipboard*Request structures are heavily influenced by
the MS-RDPECLIP spec and mirror the respective fields of
CLIPRDR_FILECONTENTS_REQUEST. wClipboard should not depend on
MS-RDPECLIP, that's the reason we don't use CLIPRDR_FILECONTENTS_REQUEST
directly. However, I believe that we should not have void* fields in the
request structs so that they can be easily copied around if needed.
This is why have the weird 'streamId' field there which has nothing to
do with wClipboard and will be used only by the clients when sending
replies to the server.

Return values of the callbacks are to be used for reporting errors with
processing the request or reply per se, not for errors encountered while
performing the action requested. Thus, for example, we return NO_ERROR
from posix_file_request_size() even when we fail to report the result to
the client, because we have successfully performed the request and do
not care if the client could not handle our reply for some reason.

Also note that setup_delegate() fills in dummy implementations of
Clipboard* reply callbacks so that we do not crash in case the client
does not fill them and do not have to perform paranoid NULL checks
before calling every single callback.
2017-04-09 03:15:49 +03:00
ilammy
28afbe61f9 wClipboard/posix: basic delegate interface
This is the thing which will be used by clients to request file sizes
and ranges from wClipboard and by wClipboard to report the results of
the requests to the clients.

wClipboard and the client will fill in the (currently absent) callbacks
with their implementations of the request-report interface and will be
using them accordingly.

Initially I thought that wClipbardDelegate would be dynamically
allocated by the client and set into wClipboard (as this would be the
case with a delegate interface implementation in OOP langauges), but
after some thought I ended up with storing the delegate in wClipboard
and using the 'void* custom' field for client-private data.

So the idea is for the subsystem to fill in its callbacks during
wClipboard construction and for the client to get access to
wClipboardDelegate with a getter and fill in its callbacks during its
clipboard initialization. The subsystem will use wClipboard* pointer to
access its data and the client will have its void* pointer to store its
context.
2017-04-09 03:15:49 +03:00
ilammy
6c6b122a37 wClipboard/posix: add directories to file list
text/uri-list contains only the files which were immediately selected by
the user. However, we need to enumerate *all* files and directories to
be pasted in CLIPRDR_FILELIST. Thus we need to walk through the
directories and add their content to the file list as well.

We use readdir() function to traverse the directory entries. It has more
sane interface than readdir_r(), but lacks (standardized) thread-safety
guarantees.  However, most C liraries guarantee that so we can use it.
There is no compile-time check because it cannot be made robust. You
deserve a crash here if you are using a C library developed by people
who cannot keep their unhealthy addiction to global state under control.

Note that recursive traversal is also a good opportunity to maintain
good remote names. We just need to concatenate the directory paths and
file names correctly.

However, this recursion has one caveat: it is not bounded, so if the
file system contains a loop then we will crash due to a stack overflow.
We could track symlink loops (and hardlinks too if we try hard) to avoid
the crash, but I think it's not a common thing to do so we can ignore
this possibility.
2017-04-09 03:15:49 +03:00
ilammy
33e80849a8 wClipboard/posix: add local files to file list
Finally we can add a file to the file list once we have got its local
file name decoded. The interesting part here is what we use for the
remote name.

Suppose the user has selected two files in different directories. In
this case we end up receiving a text/uri-list like this:

  file:///home/bob/foo/a
  file:///home/bob/bar/b

We'd expect to see "a" and "b" pasted into the remote session, so that's
what we should use for the remote names: the base names of the files.
These are the parts from the end up to the last directory delimiter.

One tricky point here is that Windows expects the file names to be
encoded in Unicode, but POSIX does not specify any particular encoding
for file names. Operating systems and file systems generally handle the
file names as mostly opaque bytes strings and do not really care what
encoding is used there. There is no portable API to get the encoding,
it's entirely up to the users and the software they use to correctly
interpret the file names. But we need to do something here.

As of 2017, the most widely used encoding for file names is UTF-8. While
there are marginal communities which stick to codepages for legacy
reasons, we can safely assume that most of the time the file names will
be encoded in UTF-8. In fact, popular desktop environments like GNOME
also assume this. So that's what we will do here as well.
2017-04-09 03:15:49 +03:00
ilammy
50038bb725 wClipboard/posix: decode percent-encoding
Nothing really interesting here, it's exactly what it says on the tin.
The percent-encoding is specified by RFC 3986. And we take care to
detect invalid encodings.
2017-04-09 03:15:49 +03:00
ilammy
64e1073044 wClipboard/posix: parse text/uri-list format
Now we start handling the actual format data. As the first step we need
to convert the text/uri-list data into the list of file names. Each file
or directory the user selects to copy is represented with a URI, and the
whole list looks like this:

  file:///home/bob/text-file
  file:///home/bob/a-directory
  file:///home/bob/white%20space

The MIME format is actually specified by RFC 2483. As said in the
comments, we allow some slack for other applications: they can use
singular LF and CR as line terminators, and we also will handle missing
terminator for the last line (some applications actually do this, but I
can't recall which ones at the moment).

We will handle only the file:// URI scheme because these refer to local
filesystem paths. It is possible for text/uri-list to contain URIs with
other schemes when the user selects files from remote filesystems (like
an FTP server or an SMB share connect to from a file manager). We cannot
pass such paths to open() and for some reason the file managers use the
remote URIs even when the remote filesystems are actually mapped to the
local filesystem via FUSE. Therefore we restrict ourselves to handling
only file://.
2017-04-09 03:15:48 +03:00
ilammy
09e73a00cb wClipboard/posix: conversion to FILEDESCRIPTORs
Now we do the actual conversion of a list of struct posix_files into an
array of FILEDESCRIPTORs. In order to correctly fill in the fields we
need to know the size of the file and whether it is a directory. This
can be looked up by stat() call. Do this during struct posix_file
construction and cache the values for later use (we will need them).

Define _FILE_OFFSET_BITS to make off_t a 64-bit value and to call
appropriate functions when we write stat() in the code. FILEDESCRIPTOR
and cliprdr protocol expect the file sizes to be 64-bit so we can
provide accurate information with that. Take care to define it before
including any system headers ("config.h" contains only defines).

Also take care to not overrun the file name buffer. Windows has a hard
cap of 260 Unicode characters for the full file name, including the
terminating null character.
2017-04-09 03:15:48 +03:00
ilammy
907f21e720 wClipboard/posix: basic file list handling
Here you can see an outline of our approach to handling file lists put
on the clipboard. Typical usage of wClipboard by the clients sums up to
doing a ClipboardSetData() call followed by a ClipboardGetData() call
with appropriate format ID passed to them. Thus for files we would
expect the clients to first set the local format (like "text/uri-list")
and then to get the remote format (the "FileGroupDescriptorW").

MS-RDPECLIP has a concept of locally-stored list of files on the
clipboard. This is modeled by clipboard->localFiles ArrayList.  We need
to populate this list before we serialize it into CLIPRDR_FILELIST and
send it to the server. The easiest way to achieve this is a bit hacky,
but it works: we populate the file list from inside the synthesizer
callback registered for text/uri-list -> FileGroupDescriptorW
conversion.

So the client would first set the data it received from local clipboard
as "text/uri-list" format, then it gets a "FileGroupDescriptorW" format,
during that conversion we will prepare to serve file content requests,
and in the end we provide a FILEDESCRIPTOR array to the client as the
conversion result. The client will then serialize the array into
CLIPRDR_FILELIST and sent it to the server. (We cannot do serialization
in WinPR as WinPR should not know about cliprdr and its data formats.)

The subsystems are expected to store their private structures in the
clipboard->localFiles array. POSIX subsystem uses struct posix_file
which currently has bare minimum of fields: the local file name (for
open() and the like) and the remote file name (the one to put into
FILEDESCRIPTOR).
2017-04-09 03:15:48 +03:00
ilammy
b0bc59595d wClipboard: local file subsystem boilerplate
This adds some initial skeleton for local file subsystems of wClipboard.

The idea is to delegate handling of local file formats to dedicated
subsystems selected at runtime based on the compiled-in support code.
This is somewhat similar to the approach used by audin, rdpsnd, rdpgfx
channels in FreeRDP.

Only one subsystem is actually used by wClipboard during runtime. It is
selected by the ClipboardInitLocalFileSubsystem() function which will
try initializing the compiled-in subsystems in the preferred order. Thus
when adding new subsystems one must make sure to 1) return as soon as
any initialization succeeds, 2) leave wClipboard in usable state if the
initialization fails.

A POSIX file subsystem is added as a pioneer. It will handle local file
format "text/uri-list" and will use POSIX API to access the files. This
is the combination one would expect to be supported by Linux systems
which can run the XFreeRDP client.

The POSIX subsystem is enabled only when CMake detects <unistd.h> as
available. This is the core POSIX include file so we can reasonably
expect the rest of the POSIX API to be available along with that file.

We also define a new configuration option WITH_DEBUG_WCLIPBOARD which
will be used to guard some debug-only verbose logging in wClipboad.
2017-04-09 03:15:48 +03:00
ilammy
228916bcec wClipboard: improve error handling
Unify error handling in ClipboardInitFormats() and actually handle the
return value of ClipboardInitSynthesizers(). Currently it always returns
TRUE, but this may change, so we'd better be clean.

Declare 'formatName' in wClipboardFormat as non-const. It is customary
in C to declare owned pointers as non-const because various deallocation
functions like free() take non-const pointers as arguments. Furthermore,
const char* is tightly associated with "string literals" which must not
be freed. Thus declaring this field as non-const is more accurate, and
removes that ugly void* cast from ClipboardInitFormats().

Unify error handling in ClipboardCreate(). The cleanup snippet should
not be repeated as it's prone to errors, like leaking the allocation of
clipboard->formats when ClipboardInitFormats() fails. Unified error
handling makes it much harder to forget resource cleanup on errors.
2017-04-09 03:15:48 +03:00
ilammy
6ad05d5ea3 winpr: define file attribute flags
The flags are defined by MS-RDPECLIP 2.2.5.2.3.1 File Descriptor
(CLIPRDR_FILEDESCRIPTOR) as well as by 'File Attribute Constants'
in WinAPI reference [1].

The idea is to delegate FILEDESCRIPTOR format processing to WinPR
instead of cliprdr channel, so move the struct definition there. The
definition used by cliprdr protocol is identical but with some fields
treated as reserved.

The defintions are placed into <winpr/shell.h> as FileGroupDescriptorW
is a shell clipboard format.

Also remove the definition of CLIPRDR_FILELIST. The clients would be
using WinPR to handle the file clipping, so CLIPRDR_FILELIST does not
have to be handled explicitly. The clients will have serialization and
deserialization functions to handle CLIPRDR_FILELIST.

[1]: https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117(v=vs.85).aspx
2017-04-09 03:15:48 +03:00
Armin Novak
6e270410ea Fixed broken scoping. 2017-04-06 17:54:44 +02:00
Armin Novak
cb815d6562 Fixed a memory leak and bad free. 2017-04-06 17:46:07 +02:00
David Fort
9fd3974817 Merge pull request #3864 from DavBfr/rewrite-disk-redirection
Rewrite disk redirection using WinPR
2017-04-06 17:32:21 +02:00
Armin Novak
4be62f7047 Fixed OpenSSL 1.1 no legacy compile issues. 2017-04-06 11:25:25 +02:00
Armin Novak
bba910bd85 Fixed RPATH settings for OS X 2017-04-06 08:08:07 +02:00
David PHAM-VAN
f54326e350 Fix indentation 2017-04-05 15:35:03 -07:00
David PHAM-VAN
30d0bde4ba Fix FindFirstFile return values 2017-03-31 15:33:28 -07:00
Armin Novak
aa11a6c89c Fixed memory leak and return value check issue. 2017-03-28 17:56:44 +02:00
Armin Novak
09d43a66f4 Fixed tests and dead store warnings. 2017-03-28 16:49:56 +02:00
David PHAM-VAN
b46aaeb973 Fix memory leaks, Mixed declarations 2017-03-27 11:15:22 -07:00
David Fort
b33371fe65 Fixed typo 2017-03-21 10:31:21 +01:00
Aric Belsito
70ab61c8e6
Support LibreSSL
Broken by the addition of OpenSSL 1.1.0 support.
2017-03-19 13:58:24 -07:00
David PHAM-VAN
5a66fe841a Misc Fixes 2017-03-17 14:07:33 -07:00
David PHAM-VAN
d6f78df195 Verify ConvertFromUnicode return values 2017-03-16 16:27:01 -07:00
David PHAM-VAN
459d3a0473 Fix Windows build 2017-03-16 16:20:48 -07:00
David PHAM-VAN
ca0398ffc2 Fix FileGetMode writable detection 2017-03-14 12:41:11 -07:00
David PHAM-VAN
9c596b70a6 Fix Android build 2017-03-14 10:48:10 -07:00
Armin Novak
3b56cd652f Fix format string is not a string literal 2017-03-14 10:56:00 +01:00
David PHAM-VAN
1c907d0b09 Fix WinPR FindFirstFile/FindNextFile functions 2017-03-13 14:19:03 -07:00
David PHAM-VAN
bc87fa69df Fix WinPR File creation functions 2017-03-13 14:18:59 -07:00
David PHAM-VAN
07c60ca8a4 Add Windows Errors to File operations 2017-03-13 14:18:55 -07:00
David PHAM-VAN
38507bae9f add _wcsrchr function 2017-03-13 14:18:42 -07:00
David PHAM-VAN
b89bfaaae4 Add missing functions to WinPR 2017-03-13 14:18:37 -07:00
Alexander Zakharov
3f139108ff Fix Stack_Peek 2017-03-13 15:45:27 +03:00
Armin Novak
b574e196d9 Fixed WLog_PrintMessagePrefixVA
WLog_PrintMessagePrefixVA is called with format being a stack variable.
Always copy the data to message->PrefixString otherwise the information
will be lost whenever the stack is destroyed.
2017-03-03 14:11:28 +01:00
Armin Novak
99c45405cb Fixed GetEnvironmentVariable. 2017-03-03 12:43:00 +01: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
Norbert Federa
97ab14add4 Added test for GetComputerName/GetComputerNameEx 2017-02-28 11:03:10 +01:00
Armin Novak
270d68f949 Fixed setting of lpnSize according to spec. 2017-02-28 09:39:04 +01:00
Armin Novak
b11de26f98 Fixed GetComputerNameExA return checks. 2017-02-27 11:49:53 +01:00
Armin Novak
71d9a83c60 Fixed GetComputerNameEx last error. 2017-02-27 11:49:53 +01:00
akallabeth
8a22052b61 Fixed memory leaks. 2017-02-25 08:35:37 +01:00
akallabeth
705c0c1e12 Fixed GetComputerNameExA calls. #3815 2017-02-24 21:58:08 +01:00
Martin Fleisz
0ed0ecb397 Merge pull request #3789 from akallabeth/scan_warning_fixes
Scanbuild warning and error fixes
2017-02-21 11:07:57 +01:00
Armin Novak
6900b5eb77 Fixed scanbuild warnings. 2017-02-20 14:32:54 +01:00
Armin Novak
e9b5d78673 Fixed scanbuild warnings. 2017-02-20 14:28:33 +01:00
Armin Novak
c249705085 Fixed scanbuild warnings. 2017-02-20 13:45:19 +01:00
Andreas Schultz
d2f98261f7 smartcard: implement ListReaderGroups
Conflicts:
	channels/smartcard/client/smartcard_operations.c
	channels/smartcard/client/smartcard_pack.c
	channels/smartcard/client/smartcard_pack.h

smartcard_operations: move handling of call argument into functions

The call argument was only use by static functions and was always equal
to operation->call. Remove the argument and use operation-call directly.

Also put the memory allocation and check into the same place.

Conflicts:
	channels/smartcard/client/smartcard_operations.c

Updated formatting and API
2017-02-16 16:59:03 +01:00
Armin Novak
198bc6d9e1 Fixed compiler warnings. 2017-02-16 13:17:49 +01:00
Martin Fleisz
ae551e4f8a Merge pull request #3762 from akallabeth/sspi_init
Use INIT_ONCE for SSPI initialisation. #3471
2017-02-16 09:51:10 +01:00
pony
a57adc3fde libwinpr-utils: fix 3 logic errors 2017-02-15 10:08:53 +01:00
Martin Fleisz
096de0f7dd Merge pull request #3755 from pentagra/master
ifdef's for Cygwin compilation
2017-02-14 12:42:10 +01:00
Armin Novak
4f44cdc561 Use INIT_ONCE for SSPI initialisation. #3471 2017-02-13 18:06:27 +01:00
Armin Novak
c90a0be205 Fixed time conversion in FileSetFileTime. #3508 2017-02-13 15:14:20 +01:00
pentagra
df2b5c9cdf ifdef's for Cygwin compilation 2017-02-10 18:06:20 +03:00
Armin Novak
656b3be02d Added fallback for CMSPAR. (See debian #854689) 2017-02-09 19:58:26 +01:00
Norbert Federa
6001cb710d Merge pull request #3717 from akallabeth/prim_fixes
Fixed primitives.
2017-02-01 11:11:27 +01:00
Martin Fleisz
c2eacd3b31 Build: Use correct pdb names when installing with symbols 2017-01-31 13:32:51 +01:00
Armin Novak
ef71f7fd55 Removed unused files, added README with links 2017-01-31 10:01:41 +01:00
Ilya Shipitsin
879f1c3944 removed redundant condition:
[winpr/libwinpr/synch/semaphore.c:131] -> [winpr/libwinpr/synch/semaphore.c:136]: (warning) Either the condition 'if(semaphore)' is redundant or there is possible null pointer dereference: semaphore.
[winpr/libwinpr/synch/semaphore.c:132] -> [winpr/libwinpr/synch/semaphore.c:136]: (warning) Either the condition 'if(semaphore)' is redundant or there is possible null pointer dereference: semaphore.
[winpr/libwinpr/synch/semaphore.c:133] -> [winpr/libwinpr/synch/semaphore.c:136]: (warning) Either the condition 'if(semaphore)' is redundant or there is possible null pointer dereference: semaphore.
[winpr/libwinpr/synch/semaphore.c:134] -> [winpr/libwinpr/synch/semaphore.c:136]: (warning) Either the condition 'if(semaphore)' is redundant or there is possible null pointer dereference: semaphore.
2017-01-28 12:36:08 +05:00