Commit Graph

3455 Commits

Author SHA1 Message Date
Armin Novak
9fb4465722 [winpr,clipboard] fix text/uri-list parsing
abort if an empty string remains
2023-03-05 17:55:28 +01:00
David Fort
7c4a774e4e winpr: fix WaitForMultipleObjectsEx(alertable) call from non winpr threads
When WaitForMultipleObjectsEx is called with the alertable flag set from a non
WinPR thread, we shall not try to treat APC, as for sure there is no APC scheduled,
as previous call that would have scheduled such APC would have failed.
2023-03-05 17:10:37 +01:00
Armin Novak
a726fa613a [winpr] improve digest failure logging 2023-03-05 17:03:18 +01:00
Armin Novak
6d0a9b075b [winpr,cynch] WINPR_ASSERT critical section functions 2023-03-01 13:45:13 +01:00
akallabeth
b4e9c8b39f [build] removed complex libraries
* remove obsolete complex libraries helper
* fix static linking
2023-03-01 08:18:34 +01:00
akallabeth
61175a96ea [winpr,clipboard] fixed mate-copied-files
wrong lineending and size fixed
2023-02-28 09:47:54 +01:00
Armin Novak
e1307b90db [winpr,clipboard] fix length of uri list
we overallocate the size, so ensure the result size only contains the
data actually used.
2023-02-28 09:47:54 +01:00
akallabeth
c9e61ff0c5 [cmake] simplify krb5 detection 2023-02-27 11:18:02 +01:00
Armin Novak
acc415442a [winpr] add macros for library options
* compile definitions
* linker options
* cflags
2023-02-27 11:18:02 +01:00
Armin Novak
f0e9797b4c [build] require CMake >= 3.13
required for target_link_options
2023-02-27 11:18:02 +01:00
Armin Novak
f4acc88c58 [winpr,clipboard] add getter for clipboard id string 2023-02-23 20:28:15 +01:00
Armin Novak
d8d4d044ff [clipboard] cleanup definitions
* remove definitions for clipboard formats that are dynamically registered
* fix length of converted clipboard string
2023-02-23 20:28:15 +01:00
Armin Novak
9cb28f47ef xxx 2023-02-21 16:42:54 +01:00
Armin Novak
1522b5aa91 xx 2023-02-21 16:42:54 +01:00
Armin Novak
3d3e577190 [winpr,clipboard] fix file list conversion 2023-02-21 16:42:54 +01:00
Armin Novak
53afedf9de [winpr,clipboard] close file after read 2023-02-21 16:42:54 +01:00
Armin Novak
10404121c4 [winpr,clipboard] fix error message format string 2023-02-21 16:42:54 +01:00
Armin Novak
62028f1488 [winpr,file] map EMFILE 2023-02-21 16:42:54 +01:00
akallabeth
2f05166fb1 [winpr,crypto] improve logging 2023-02-03 11:09:59 +01:00
akallabeth
f2b4fa9acc [winpr,sspi] fix const correctness of function argument
sspi_SetAuthIdentityWithUnicodePassword arguments should be const to
avoid compiler warnings if the variable is also const
2023-02-01 09:51:54 +01:00
akallabeth
ee07a13130 [cleanup] fix compiler warnings 2023-01-26 09:30:17 +01:00
Armin Novak
1dc2225bd2 [winpr,wlog] include function name in log message
default to print the function the log message was called from
2023-01-25 16:26:39 +01:00
Armin Novak
641022b795 [logging] remove __FUNCTION__ from actual message
prefer the log formatter to provide that information.
2023-01-25 16:26:39 +01:00
akallabeth
de40b43037 [winpr,stream] modify logging stream length checks
* Split length argument to nmemb and size for all Stream_CheckAndLogRequiredLength* functions
* Add new macros to allow setting nmemb and size arguments
2023-01-25 14:27:32 +01:00
akallabeth
74530a7931 [format strings] ensure __LINE__ is of type size_t
__LINE__ is not particularily well defined (most fall back to int).
We want to ensure that all the uses in a format string match the format
specifier, so do an explicit cast
2023-01-25 14:27:32 +01:00
akallabeth
8ed37e68d2 [stream] use logging capacity checks 2023-01-25 14:27:32 +01:00
akallabeth
b6648288e4 [winpr,stream] add functions to check and log capacity
Add functions (and macros) to provide a method to check the remaining
capacity of a stream and log failures
* Stream_CheckAndLogRequiredCapacityWLog
* Stream_CheckAndLogRequiredCapacityWLogEx
* Stream_CheckAndLogRequiredCapacityWLogExVa
2023-01-25 14:27:32 +01:00
Armin Novak
f62c658e17 [winpr] Make Stream_SafeSeek log a failure 2023-01-24 10:16:55 +01:00
Armin Novak
2d16ab5255 [winpr,sam] fix inalid NULL arguments 2023-01-11 21:37:16 +01:00
Armin Novak
39210d1efd [winpr,sam] allow empty domain in SamLookupUserW 2023-01-11 21:37:16 +01:00
akallabeth
92d3e3c64a [winpr] use WINPR_ prefix for conditional includes 2023-01-10 17:38:00 +01:00
akallabeth
2479ebd816 Fixed compiler warnings 2023-01-10 17:38:00 +01:00
David Fort
9e3bc8e3af wtsapi: add new kind of query to retrieve the open status 2022-12-27 11:02:29 +01:00
Armin Novak
b917dbad32 [winpr,stream] add length check helper 2022-12-22 15:09:03 +01:00
Armin Novak
7a95c7343d [winpr,wlog] fixed noisy wlog filter 2022-12-22 15:09:03 +01:00
akallabeth
784becd946 [winpr,image] add winpr_bitmap_write_ex
Added a helper function writing a bitmap from an image that has a stride
that is not width * <bytes per pixel>
2022-12-16 11:03:13 +01:00
Armin Novak
51e49b4329 [winpr,asn] Fixed a compiler warning
WinPrAsn1DecReadEnumerated expects an argument of type
WinPrAsn1_ENUMERATED* so ensure the variable referenced is of said type.
2022-12-15 14:57:29 +01:00
David Fort
e915b294d5 winpr: add functions to test for read / write availability in pollset 2022-12-13 15:54:33 +01:00
fifthdegree
497ada661f Change the logic flow on error to a better style
Use do-while and break instead of checking return value before every
line
2022-12-13 14:26:45 +01:00
fifthdegree
e4b82cf0ef [kerberos] Assert expected pointer arguments 2022-12-13 14:26:45 +01:00
fifthdegree
3ffc32176d Support heimdal kerberos implementation
Add support for heimdal kerberos in addition to mit kerberos
2022-12-13 14:26:45 +01:00
fifthdegree
6c8e4d668d Don't free empty structures 2022-12-13 14:26:45 +01:00
fifthdegree
1e6c5fc782 Allow setting kdc hostname
Use user-provided kdc hostname when given
2022-12-13 14:26:45 +01:00
akallabeth
37ab25e19d Fixed all Wdocumentation warnings 2022-12-12 14:24:55 +01:00
akallabeth
d4808dd3e1 Fixed various compiler warnings 2022-12-09 15:58:26 +01:00
akallabeth
7ab917dca8 Fixed Wsign-compare warnings 2022-12-09 15:58:26 +01:00
Armin Novak
bd7e2263ad fixed const and type cast warnings 2022-12-09 15:58:26 +01:00
akallabeth
0186a9b303 Fixed some warnings 2022-12-09 15:58:26 +01:00
akallabeth
99ad9db4e6 [winpr,path] Fixed WCHAR and char mixup 2022-12-09 15:58:26 +01:00
akallabeth
e86f49d7d7 [winpr,utils] eliminate integer conversion warning 2022-12-09 15:58:26 +01:00
akallabeth
873a11aa10 [winpr,path] Eliminate unreachable code 2022-12-09 15:58:26 +01:00
akallabeth
7f221a653d Fixed Wpedantic warnings 2022-12-09 15:58:26 +01:00
akallabeth
7894cf545c Fixed Wmissing-varialbe-declarations warnings 2022-12-09 15:58:26 +01:00
akallabeth
a3686f0f1f Fixed Wmissing-prototypes warnings 2022-12-09 15:58:26 +01:00
akallabeth
3ddf99ad64 Fixed Wformat warnings 2022-12-09 15:58:26 +01:00
akallabeth
7e31b877fc [winpr, tests] Fixed ASN unit test const warning 2022-12-09 15:58:26 +01:00
akallabeth
389817cb57 [winpr,crypto] fixed const correctness of md4/5 2022-12-09 15:58:26 +01:00
akallabeth
aaae70ff05 Fixed missing const casts 2022-12-09 15:58:26 +01:00
akallabeth
bf0ce5bf3a [winpr,sspi] Fixed const correctness of API
sspi_GetAuthIdentityVersion and sspi_GetAuthIdentityFlags do not
modify, make arguments const
Same is true for sspi_GetAuthIdentityUserDomainW,
sspi_GetAuthIdentityUserDomainA, sspi_GetAuthIdentityPasswordA and
sspi_GetAuthIdentityPasswordW
2022-12-09 15:58:26 +01:00
Armin Novak
558d5b5e8d [build,ci] update ci to not always build kerberos
disable kerberos for targets not supporting it
2022-12-09 12:36:12 +01:00
Armin Novak
73d5f37537 [build] move krb5 detection to winpr
only used internally in winpr, no need for project wide configuration
2022-12-09 12:36:12 +01:00
Armin Novak
f2016c77c5 [winpr] renamed WITH_GSS_NO_NTLM_FALLBACK 2022-12-09 12:36:12 +01:00
Armin Novak
819a62a8df Disable kerberos support for android and ios 2022-12-09 12:36:12 +01:00
Armin Novak
2fdae68bbd [build] disable krb5 support on windows
windows provides native support, no need for libkrb5
2022-12-09 12:36:12 +01:00
fifthdegree
ad87144ce5 Rename WITH_GSSAPI to WITH_KRB5
Change cmake variables to not be gssapi specific
2022-12-09 12:36:12 +01:00
akallabeth
fb6c48bcc3 [winpr] define WINPR_ASSERT to assert
If WITH_VERBOSE_WINPR_ASSERT is not set define WINPR_ASSERT to be the
normal C assert
2022-12-09 11:09:38 +01:00
akallabeth
c7bd8c3df9 [winpr,sspi] fix kerberos resource cleanup
kerberos cache and keytab were not properly cleaned up for cases where
the credentials were not available in kerberos
2022-12-09 11:08:11 +01:00
akallabeth
6613155275 [winpr,utils] pretty print stacktrace
do not add an additional newline in the messages.
2022-12-09 10:28:40 +01:00
Armin Novak
074f28073a [winpr,sspi] enable negotiate by default 2022-12-08 11:07:00 +01:00
akallabeth
9ca34bc876 [winpr,sspi] fix memory leak in kerberos_InitializeSecurityContextA 2022-12-02 15:08:09 +01:00
akallabeth
b0aef46caf [winpr,krb] fixed kerbeos context handling 2022-12-02 15:08:09 +01:00
Armin Novak
e1eacad74c [scard] fixed memory leak
card_id_and_name_* return allocated values, free after use
2022-12-02 15:08:09 +01:00
Armin Novak
58bc1ee4c9 [smartcard] fix multi string conversion 2022-12-02 15:08:09 +01:00
David Fort
bc8afa0ad5 ncrypt_pkcs11: fix buffer allocation for key name 2022-12-02 15:08:09 +01:00
Armin Novak
0091f72761 [winpr,smartcard] fix PCSC_SCardListReaders 2022-12-02 15:08:09 +01:00
Armin Novak
bbf893a5d8 [winpr,crt] fix unicode conversion functions
There are subtle differences between MultiByteToWideChar,
WideCharToMultibyte and the ICU equivalents
2022-11-29 15:42:10 +01:00
akallabeth
6014efc19b [winpr,smartcart] simplified casts 2022-11-28 10:42:36 +01:00
akallabeth
66dad5deae fixed review issues
* Overallocation in unicode functions
* Removed useless statements
* Fixed loop indices
2022-11-28 10:42:36 +01:00
akallabeth
7bf8b46726 [smartcard] Use multistring convertion functions 2022-11-28 10:42:36 +01:00
Armin Novak
2784d54d6f Deprecate MultiByteToWideChar and WideCharToMultiByte 2022-11-28 10:42:36 +01:00
Armin Novak
6f2d7f94cf Deprecate ConvertFromUnicode and ConvertToUnicode 2022-11-28 10:42:36 +01:00
akallabeth
5799fb2018 Replace ConvertFromUnicode and ConvertToUnicode
* Use new ConvertUtf8ToWChar, ConvertUtf8NToWChar,
  ConvertUtf8ToWCharAlloc and ConvertUtf8NToWCharAlloc
* Use new ConvertWCharToUtf8, ConvertWCharNToUtf8,
  ConvertWCharToUtf8Alloc and ConvertWCharNToUtf8Alloc
* Use new Stream UTF16 to/from UTF8 read/write functions
* Use new settings UTF16 to/from UTF8 read/write functions
2022-11-28 10:42:36 +01:00
Armin Novak
2aefa9418d [winpr,stream] Added functions to read/write utf-8
* Stream_Write_UTF16_String_From_UTF8 writes a UTF-8 string to a
      stream in UTF-16 encoding
    * Stream_Read_UTF16_String_To_UTF8 reads a UTF-16 encoded string
      from the stream and returns it in UTF-8 encoding
2022-11-28 10:42:36 +01:00
Armin Novak
0fb8c9e87e [winpr,crt] Added ConvertMszWCharNToUtf8* 2022-11-28 10:42:36 +01:00
akallabeth
4f7114a140 [winpr,crt] Added ConvertMszUtf8NToWChar*
A conversion function that can handle multistrings (e.g. each element is
'\0' delimited, termination is '\0\0')
2022-11-28 10:42:36 +01:00
akallabeth
5c91c30a18 [winpr,crt] Added new unicode conversion functions
* Added functions converting WCHAR to/from UTF-8 with given buffers
  and proper size_t arguments to have a centralized check for
  integer overflows on RDP deserialization
* Added allocating functions converting WCHAR to/from UTF-8 as
  convenience
2022-11-28 10:42:36 +01:00
akallabeth
5ae159303f [winpr,crt] Added unicode conversion backends
* Support apple with NSString
* Support android via JNI
* Split ICU to own file
2022-11-28 10:42:36 +01:00
akallabeth
00ee213f97 [winpr,android] Unify JNI_OnLoad
* Split JNI_OnLoad and JNI_OnUnload to own module to be usable from more
  than only timezone
* Explicitly call System.loadLibrary('winpr') (and other FreeRDP
  libraries) in android client as JNI_OnLoad is only triggered by that
  and not implicit loading
2022-11-28 10:42:36 +01:00
akallabeth
113290c35c [winpr,string] Use size_t arguments
* Use size_t arguments for ByteSwapUnicode, ConvertLineEndingToLF
  and ConvertLineEndingToCRLF
* Simplify code of line conversion functions
2022-11-28 10:42:36 +01:00
akallabeth
3262e11d1f [winpr,asn] fix too verbose log message 2022-11-24 11:43:01 +01:00
Armin Novak
7b95014157 [winpr,crypto] Split crypto header renamed
* Renamed custom winpr crypto function header
* Added compatiblity header
2022-11-23 09:39:56 +01:00
Armin Novak
d03f230426 [winpr,crypto] Split headers
Split windows API emulation from custom functions
Including both might yield issues with OpenSSL headers
2022-11-21 13:27:08 +01:00
Armin Novak
f81b3b05d2 Fixed -Wtautological-value-range-compare 2022-11-21 10:12:31 +01:00
Armin Novak
7c5652c15a Fixed -Wmissing-prototypes 2022-11-21 10:12:31 +01:00
Armin Novak
a40ade5abc Fixed -Wincompatible-pointer-types 2022-11-21 10:12:31 +01:00
Armin Novak
bc7c4cc6a1 Fixde -Wimplicit-function-declaration 2022-11-21 10:12:31 +01:00
Armin Novak
9adc1e4b08 Fixed -Wunreachable-code-return 2022-11-21 10:12:31 +01:00
Armin Novak
31c1700c0c Fixed -Wunused-variable 2022-11-21 10:12:31 +01:00
Armin Novak
921315fdbf Fixed -Wmissing-variable-declarations 2022-11-21 10:12:31 +01:00
Armin Novak
dacebc62a3 Use Stream_CheckAndLogRequiredLength, fix WLog TAG
* Log stream length requirement violations
* Use proper defines for WLog tags
2022-11-21 09:57:27 +01:00
Armin Novak
43eccb6247 [winpr,io] removed unused unimplemented functions 2022-11-21 09:16:54 +01:00
Mike Gilbert
3053543068 winpr/string.h: #include <stdio.h> for snprintf
Fixes failure with -Werror=implicit-function-declaration.

```
FAILED: libfreerdp/CMakeFiles/freerdp.dir/core/state.c.o
/usr/bin/ccache /usr/bin/cc -DEXT_PATH=\"/usr/local/lib64/freerdp3/extensions\" -DFREERDP_EXPORTS -DNDEBUG -DWITH_OPENSSL -DWITH_VERBOSE_WINPR_ASSERT -DWITH_WAYLAND -DWITH_X11 -DWITH_XKBFILE -D_FILE_OFFSET_BITS=64 -Dfreerdp_EXPORTS -I/home/floppym/src/FreeRDP/winpr/include -I/home/floppym/src/FreeRDP/build/winpr/include -I/home/floppym/src/FreeRDP/build -I/home/floppym/src/FreeRDP/build/include -I/home/floppym/src/FreeRDP/include -Werror=implicit-function-declaration -fPIC -Wall -fvisibility=hidden -Wimplicit-function-declaration -Wredundant-decls -fno-omit-frame-pointer -O3 -DNDEBUG -flto=auto -fno-fat-lto-objects -fPIC -std=gnu11 -MD -MT libfreerdp/CMakeFiles/freerdp.dir/core/state.c.o -MF libfreerdp/CMakeFiles/freerdp.dir/core/state.c.o.d -o libfreerdp/CMakeFiles/freerdp.dir/core/state.c.o -c /home/floppym/src/FreeRDP/libfreerdp/core/state.c
In file included from /home/floppym/src/FreeRDP/libfreerdp/core/state.c:24:
/home/floppym/src/FreeRDP/libfreerdp/core/state.c: In function ‘state_run_result_string’:
/home/floppym/src/FreeRDP/winpr/include/winpr/string.h:186:19: error: implicit declaration of function ‘snprintf’ [-Werror=implicit-function-declaration]
  186 | #define _snprintf snprintf
      |                   ^~~~~~~~
/home/floppym/src/FreeRDP/libfreerdp/core/state.c:67:9: note: in expansion of macro ‘_snprintf’
   67 |         _snprintf(buffer, buffersize, "%s [%d]", name, status);
      |         ^~~~~~~~~
/home/floppym/src/FreeRDP/libfreerdp/core/state.c:25:1: note: include ‘<stdio.h>’ or provide a declaration of ‘snprintf’
   24 | #include <winpr/string.h>
  +++ |+#include <stdio.h>
   25 |
/home/floppym/src/FreeRDP/winpr/include/winpr/string.h:186:19: warning: incompatible implicit declaration of built-in function ‘snprintf’ [-Wbuiltin-declaration-mismatch]
  186 | #define _snprintf snprintf
      |                   ^~~~~~~~
/home/floppym/src/FreeRDP/libfreerdp/core/state.c:67:9: note: in expansion of macro ‘_snprintf’
   67 |         _snprintf(buffer, buffersize, "%s [%d]", name, status);
      |         ^~~~~~~~~
/home/floppym/src/FreeRDP/winpr/include/winpr/string.h:186:19: note: include ‘<stdio.h>’ or provide a declaration of ‘snprintf’
  186 | #define _snprintf snprintf
      |                   ^~~~~~~~
/home/floppym/src/FreeRDP/libfreerdp/core/state.c:67:9: note: in expansion of macro ‘_snprintf’
   67 |         _snprintf(buffer, buffersize, "%s [%d]", name, status);
      |         ^~~~~~~~~
cc1: some warnings being treated as errors
```

Bug: https://bugs.gentoo.org/881695
2022-11-18 06:43:11 +01:00
Richard E. Silverman
7bbb8706ee fix segfault on missing CSP
These routines:

  NCryptOpenStorageProvider()
  winpr_NCryptOpenStorageProviderEx

would segfault with PKCS11 support enabled, if the user did not supply
a service provider name ("CSP"); they assumed the parameter
pszProviderName would always be non-NULL, but it's NULL in that case.
2022-11-16 14:18:22 +01:00
akallabeth
d71174d091 [winpr, crt] Added wcsstr implementation 2022-11-14 09:28:22 +01:00
akallabeth
cf5cb35697 [winpr, crt] Fix wcs*cmp and wcs*len checks 2022-11-14 09:28:22 +01:00
akallabeth
ed57dd37b9 Added function _wcsncmp
* Compare WCHAR strings up to n characters
2022-11-14 09:28:22 +01:00
Armin Novak
843680e543 Clipboard syntesizer replaces path separators
The clipboard expects windows style paths, so replace all / with \
2022-10-28 08:22:43 +02:00
Armin Novak
f9faf3d3d5 Unified synthetic file cleanup 2022-10-28 08:22:43 +02:00
Armin Novak
a7a8e7ee8d Fixed read/write of filedescriptorw times 2022-10-28 08:22:43 +02:00
Armin Novak
096e98d8b5 Moved verbose log message
Do not log expected abort conditions
2022-10-28 08:22:43 +02:00
Armin Novak
dbb1889a54 Removed unused BipBuffer 2022-10-27 10:39:25 +02:00
Armin Novak
4ea4f5e936 Fixed compile error for old openssl 2022-10-27 10:03:32 +02:00
akallabeth
22dce52d15 Add function winpr_MoveFileEx 2022-10-25 13:58:05 +02:00
fifthdegree
78ba60f50f Check for NULL pointer in winpr_Digest_Free 2022-10-24 08:33:57 +02:00
akallabeth
68ad8d5a1c Added missing return in winpr_Digest_New 2022-10-20 19:24:41 +02:00
Armin Novak
2a181c19c5 Added missing include 2022-10-19 20:33:17 +02:00
Armin Novak
a66d9d1706 Improve OpenSSL provider loading
* Added log messages for failure to load a provider
* Add code to clean up loaded providers on shutdown
2022-10-19 20:33:17 +02:00
Armin Novak
1f6476016d Update command line option /sec*
* Deprecate /sec-* flags
* Allow multiple arguments for /sec
2022-10-19 20:31:53 +02:00
fifthdegree
ffe8e45aff Pass bindings through Negotiate on first call 2022-10-19 18:55:38 +02:00
fifthdegree
e847f159a6 Try to use the smartcard key name Windows uses
Windows expects the containerName field in TSSmartCardCreds to be what
it would use for a smartcard key's name. Try to accomodate that (at
least for PIV and GIDS cards).
2022-10-19 18:55:38 +02:00
akallabeth
eb77fd7b0d Added replacement HMAC-MD5 implementation 2022-10-19 08:17:11 +02:00
akallabeth
3a5fb5e3a3 Added replacement MD5 implementation 2022-10-19 08:17:11 +02:00
akallabeth
309a6bea77 Added replacement MD4 implementation 2022-10-19 08:17:11 +02:00
akallabeth
1e1b3b6c3c Updated TestCryptoHash
Do multiple updates to hashes to better test implementation
2022-10-19 08:17:11 +02:00
akallabeth
43c5289928 Replaced memset/ZeroMemory with initializer
* Addes WINPR_ASSERT on many occations
* Replaced memset with array initializer
* Replaced ZeroMemory with array initializer
2022-10-14 12:11:01 +02:00
David Fort
57d2a27980 fix smartcard listing
This commit fixes various bugs that I've noticed on some windows systems with
smartcards that contains multiple certificates:

* With some drivers if you retrieve the ATR while enumerating the NCrypt keys, it seems to
confuse the NCrypt key context (and you're unable to retrieve certificate property). As
we don't use the ATR, let's remove the ATR retrieval.
* if don't give any user or domain on the command line, in settings you get User=Domain=NULL,
but if you pass /u:user, you get User="user" and Domain = ""(empty string not NULL). The
smartcard filtering by user/domain was not ready for that.
2022-10-14 12:05:16 +02:00
akallabeth
b70db86e51 Fixed uninitialized variable warnings 2022-10-14 11:16:23 +02:00
akallabeth
bba18b7af5 Fixed -Waddress warnings 2022-10-13 14:38:06 +02:00
Armin Novak
1d71ace487 Fixed PubSub, return error on NULL 2022-10-13 13:57:11 +02:00
David Fort
f76c14c256 fix smartcard logon with smartcard emulation
When smartcard emulation was enabled we were dumping the key and cert to
temporary files for PKINIT call, but they were deleted before we have
actually done the PKINIT. This patch fixes it.

It also add debug statement for the listing of smartcard keys / certs.

This also fixes the listing of smartcard on certain windows configurations
were we have to force NCRYPT_SILENT when doing a NCryptOpenKey.
2022-10-13 12:03:58 +02:00
Marc-André Moreau
27a865af74 Add Negotiate SSPI authentication module filtering 2022-10-12 22:07:45 +02:00
akallabeth
2f84a4856c Fixed missing-field-initializers warnings 2022-10-11 13:28:30 +02:00
akallabeth
9d197b263c Fixed conditional-uninitialized warnings 2022-10-11 13:28:30 +02:00
akallabeth
23082b090c Removed misleading comments 2022-10-11 13:28:30 +02:00
Martin Fleisz
b45f580055 sspi: Do not call copy on empty strings
It might happen that the username/domain/password strings are set to an
empty string. This means that the null pointer check will pass but the
application will assert in the copy helper function.

This fix simple checks the length of the identity strings and only calls
copy in case the length is greater than 0.
2022-10-11 12:15:47 +02:00
Armin Novak
5476d48025 Use Stream_StaticInit for bitmap read 2022-10-10 15:29:45 +02:00
Armin Novak
d879d87610 Use static wStream for packet logger 2022-10-10 15:29:45 +02:00
David Fort
58a3919435 winpr: add some checks in InitializeSecurityContext and AcceptSecurityContext
In native windows SSPI, AcceptSecurityContext and InitializeSecurityContext return
SEC_E_INVALID_HANDLE if the provided context is an empty context. Add the checks so
that our SSPI implementation behave the same way.
2022-10-10 09:01:04 +02:00
fifthdegree
d6c614b583 Fix bugs and add features in sspi packages
* Kerberos: correctly set principal when no service part is provided
* Kerberos: don't expect a krb_ap_rep when mutual auth was not requested
* Kerberos: include gss header in max signature length
* Negotiate: tolerate optimistic token being the final one
* Kerberos: support channel bindings
* Negotiate: pass channel bindings to sub-mechanism
* NTLM: tolerate receiving an input buffer desc on first call
2022-10-06 21:33:01 +02:00
Marc-André Moreau
479e891545 check return values for SetCredentialsAttributes, throw warnings for unsupported attributes 2022-09-30 19:33:12 +02:00
Marc-André Moreau
fddb0dac75 add missing OOM checks 2022-09-30 19:33:12 +02:00
Marc-André Moreau
eadbb15741 run clang-format 2022-09-30 19:33:12 +02:00
Marc-André Moreau
80a1fc6a98 add SetCredentialsAttributes SSPI function 2022-09-30 19:33:12 +02:00
Marc-André Moreau
ee233eac39 add SetCredentialsAttributes(SECPKG_CRED_ATTR_KDC_URL) in Kerberos SSPI module 2022-09-30 19:33:12 +02:00
Marc-André Moreau
3224a43ee3 use SecurityFunctionTable version 3 with SetCredentialsAttributes function pointer 2022-09-30 19:33:12 +02:00
Marc-André Moreau
c7af6fabe0 add SetCredentialsAttribute to SecurityFunctionTable 2022-09-30 19:33:12 +02:00
Marc-André Moreau
61e5bdec6a add missing SSPI credential attribute IDs and structs 2022-09-30 19:33:12 +02:00
Marc-André Moreau
23f66f3987 add KDC URL to internal SSPI Kerberos settings 2022-09-30 19:33:12 +02:00
akallabeth
1849632c43
Fixed format strings to match arguments (#8254)
* Fixed format strings to match arguments

Reviewed and replaced all %d specifiers to match proper type

* Added proxy dynamic channel command type to log messages.
2022-09-29 14:55:27 +02:00
David Fort
c5c2e37f6d
More winpr fixes (#8255)
* Fix build with mingw

4a71cab2e7 broke wf_events.c.
The drive channel was not building because of missing definitions.

* winpr: make functions return False when not implemented
2022-09-28 16:07:04 +02:00
Kang Lin
71b48f61c1 WinPR::Clipboard::SyntheticFile: FIX match *.* directory bug. The FilePatternMatchA don't support *.* pattern 2022-09-27 09:27:27 +02:00
Armin Novak
ba2e5477d1 Added additional checks and fixed WCHAR usage. 2022-09-26 14:01:20 +02:00
Kang Lin
195b98a9a9 WinPR::Clipboard: Refactor synthetic file
rename posix.c to synthetic_file.c
2022-09-26 14:01:20 +02:00
David Fort
e944d8d243 winpr: improve WaitForSingleObject and WaitForMultipleObject with processes
This patch improves waiting on process handles:
* under linux we take advantage of pidfd if available, when it can be used it
allows to have one or more process in the objects that are WaitForMultipleObject-ed.
* the patch also make the code honor the timeout parameter during a WaitForSingleObject and
possibly run completion when WaitForSingleObjectEx is executed with alertable set to true
2022-09-26 12:08:00 +02:00
akallabeth
d2ab631c40
Test uri fix (#8232)
* Fixed TestUri unit test

* Make proper unit test out of the test function
* Add proper test cases

* Replace FindFirstFileA with FindFirstFileW for addins

This allows addin paths to contain unicode symbols.

* Fixed parse_uri_to_local_file definition

* Move to common clipboard.c file
* Move to header file so it can be included in test case

* Added WINPR_LOCAL for test builds

This macro exports internal functions in case of a unit test build
This way unit tests can access these without other workarounds.

* Fixed typo in function name is_dos_driver

* Cleaned up FindFirstFileW call

Use a wrapper function to convert to unicode and call the function

* Cleaned up BUILD_TESTING and EXPORT_ALL_SYMBOLS

* EXPORT_ALL_SYMBOLS now does as the name implies and exports all
  non static functions/variables from the library.
* BUILD_TESTING now only sets the defines for test code and
  activates EXPORT_ALL_SYMBOLS to allow tests to access internal
  code

* Fixed windows client warnings

* disable CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
2022-09-26 11:22:02 +02:00
David Fort
ccffa8dfa2 winpr: add a function to export timer file descriptor
The equivalent exist for Events, and it happens that sometime you also need to access
the internal file descriptor associated with a timer.
2022-09-23 09:04:45 +02:00
David Fort
56204164fe core: check the kind of object for events and threads functions
This patch adds some checks for the type of object in Event and Thread functions,
this may help to find bugs where a handle with the wrong type is used as argument
of these functions.
2022-09-21 16:04:02 +02:00
Zopolis4
2145cef543 Restrict overmatching MACH ifdef to only trigger on OSX and Mach 2022-09-21 09:09:16 +02:00
David Fort
ee9c9e7c48 Remove duplicated definitions for file constants 2022-09-21 09:03:45 +02:00
David Fort
3dcc4f4024 fix build for mingw-clang 2022-09-21 09:03:45 +02:00
Armin Novak
ee6317081b Improve string version extraction regex
Allow (git) tags of format 'some-important-text_v1.2.3-something_else'
Any character is now allowed, as long as there is a version of format
1.2.3 somewhere in the tag name.
2022-09-20 13:25:44 +02:00
Armin Novak
e7973d15ff Fix out of bounds reads in parse_uri_to_local_file 2022-09-19 11:06:40 +02:00
Kang Lin
6a6e3340c7 WinPR::Clipboard: Add to convert uri to local file
URI is specified by RFC 8089: https://datatracker.ietf.org/doc/html/rfc8089

Local files:

   o  A traditional file URI for a local file with an empty authority.
      For example:

      *  "file:///path/to/file"

   o  The minimal representation of a local file with no authority field
      and an absolute path that begins with a slash "/".  For example:

      *  "file:/path/to/file"

   o  The minimal representation of a local file in a DOS- or Windows-
      based environment with no authority field and an absolute path
      that begins with a drive letter.  For example:

      *  "file:c:/path/to/file"

   o  Regular DOS or Windows file URIs with vertical line characters in
      the drive letter construct.  For example:

      *  "file:///c|/path/to/file"

      *  "file:/c|/path/to/file"

      *  "file:c|/path/to/file"
2022-09-16 11:41:43 +02:00
Armin Novak
09275bf4c7 Disable execinfo support if only header detected
Some implementations (e.g. Android with API < 33) provide the
execinfo.h header file, but do not define the backtrace functions
expected. Disable the support for execinfo backtrace in such a case
2022-09-16 08:43:19 +02:00
Néfix Estrada
66bef0c708 feat(emscripten): add support for emscripten compilation 2022-09-15 10:23:43 +02:00
akallabeth
43dc14f94b
Fix possible out of bound write in winpr_read_unix_timezone_identifier_from_file (#8207)
If the timezone can not be read from the file (read 0 bytes) then memory
at a random position (buffer[-1] = '\0') will be set to zero.
2022-09-14 16:26:24 +02:00
Armin Novak
8561b08592 Fixed gnome and mate clipboard format synthesizers 2022-09-13 14:42:33 +02:00
Armin Novak
b3f70b047d Fix OId compare 2022-09-13 09:16:55 +02:00
Kang Lin
0faa2c91fe WinPR::Clipboard: FIX text/uri-list format bug(#7904)
See:
  GTK: https://docs.gtk.org/glib/struct.Uri.html
  uri syntax: https://www.rfc-editor.org/rfc/rfc3986#section-3
  uri-lists format: https://www.rfc-editor.org/rfc/rfc2483#section-5
2022-09-12 08:58:34 +02:00
David Fort
4fc7a9417d
Various fixes / improvements (#8146)
* xfreerdp: fix typo in logs

* winpr: file appender, small code cleanup

* shadow-server: add an option for TLS secrets

This allows to dissect connections to the shadow server.
2022-08-22 09:42:15 +02:00
fifthdegree
7901a26a16
Kerberos User 2 User support (#8070)
* add support for 64-bit big-endian encoding

* kerberos: drop reliance on gssapi and add user 2 user support

* Fix local variable declared in the middle of the function body

* kerberos: add ccache server option

Co-authored-by: fifthdegree <fifthdegree@protonmail.com>
Co-authored-by: David Fort <contact@hardening-consulting.com>
2022-08-17 12:25:26 +02:00
David Fort
c9eea58ef2
winpr: set non-blocking on both fd with pipe() based events (#8106) 2022-08-03 08:30:51 +02:00
David Fort
da10710cf9
winpr: complement thread tests and fix some asserts (#8105) 2022-08-02 11:40:55 +02:00
akallabeth
bf56a39e6f
Fixed #8090: Duplicate definition of strndup (#8102)
* Fixed #8090: Duplicate definition of strndup

* Moved strndup detection to winpr

Co-authored-by: Armin Novak <anovak@thincast.com>
2022-08-02 09:15:38 +02:00
David Fort
1f08cb9a7d
Drdynvc needs love (#8059)
* winpr: add lock operation on HashTables

* drdynvc: change the listeners array for a hashtable and other micro cleanups

* logonInfo: drop warning that is shown at every connection

Let's avoid this log, we can't do anything if at Microsoft they don't respect
their own specs.

* rdpei: fix terminate of rdpei

* drdynvc: implement the channel list with a hashtable by channelId
2022-07-26 12:53:41 +02:00
David Fort
48abc64a6d winpr: update WinPrAsn1DecReadContextualOctetString to use common code 2022-07-26 09:38:53 +02:00
fifthdegree
5f3bc5842a nla: use winpr asn1 library 2022-07-26 09:38:53 +02:00
fifthdegree
8fb49e1f31 ncrypt_pkcs11: enumerate keys by public keys 2022-07-21 18:38:36 +02:00
David Fort
90aaea0a55
winpr asn1: fix error reporting of ReadContextualXXX functions (#8085) 2022-07-21 16:00:57 +02:00
Martin Fleisz
b93f742896 winpr: Add missing include for windows build 2022-07-21 15:59:43 +02:00
fifthdegree
54bbe33123
spnego: add missing check (#8069)
Co-authored-by: fifthdegree <fifthdegree@protonmail.com>
2022-07-15 08:33:28 +02:00
fifthdegree
dfa231c0a5
spnego: correctly set output buffer size (#8060)
Co-authored-by: fifthdegree <fifthdegree@protonmail.com>
2022-07-12 10:08:44 +02:00
Armin Novak
586675942a Fixed missing return 2022-07-07 17:31:49 +02:00
Armin Novak
36c7c0320b Fixed review comments 2022-07-07 17:31:49 +02:00
fifthdegree
362ae93a64 spnego: some cleanups and fixes 2022-07-07 17:31:49 +02:00
David Fort
8b5df3fa92 spnego: cleanup the guess of the input token 2022-07-07 17:31:49 +02:00
David Fort
b128ec4fba spnego: add various check and fixes 2022-07-07 17:31:49 +02:00
David Fort
6c834eaa15 winpr: adjust negotiate_GetMechByOID function 2022-07-07 17:31:49 +02:00
fifthdegree
2a3c92b4cc spnego: use winpr asn.1 library 2022-07-07 17:31:49 +02:00
Pascal Nowack
43b609cd6c winpr/clipboard: Allow overriding ValidFileNameComponent call
When using the wClipboard API, the connected peer might not be on the
Windows platform, where further filename restriction exists.
As a result, it is currently not possible to use the wClipboard API,
when intending to allow filenames, containing characters like ':'.

So, add a callback to the wClipboardDelegate, which is set to the
ValidFileNameComponent call by default.
This callback can be overridden by the API user, when it is known, that
there is no need to impose very strict filename restrictions.
2022-07-07 07:45:26 +00:00
David Fort
168117e85b winpr: fix encoding of octetString containers and add required functions for SPNego 2022-07-05 15:04:01 +02:00
akallabeth
05b339b0b1 Added strndup replacement 2022-07-04 14:31:08 +02:00
akallabeth
1f398c6c51 Added missing include 2022-07-02 16:32:50 +02:00
akallabeth
51f4c374c4 Clear OpenSSL error queue before BIO_read/BIO_write 2022-07-02 16:32:50 +02:00
David Fort
bddb71230e winpr asn1: fixes and more features
This patches adds support for octet string containers that are used by SPNego
(a subfield is contained in an octet string record).
It also adds a performance test to test reallocations in asn1 encoder.
It fixes reallocation problems for both chunks and containers.
2022-07-01 09:43:01 +02:00
David Fort
cbda255dcd winpr: add some ASN1 parsing functions
This patch implements ASN1 parsing in WinPR, as we need it in SSPI packages.
2022-07-01 07:51:31 +02:00
akallabeth
5d1d3d6582 Fixed #8022: leaks in kerberos code 2022-06-30 23:00:48 +02:00
akallabeth
39bd78d2fb Fixed missing includes 2022-06-29 18:10:33 +02:00
akallabeth
7c85949f1d Fixed unused variable warnings 2022-06-29 18:10:33 +02:00
akallabeth
99cda9249f Fixed uninitialized warnings 2022-06-29 18:10:33 +02:00
akallabeth
684ada9c0e Fixed uninitialized warnings 2022-06-29 18:10:33 +02:00
akallabeth
7faf18d9dd Updated flags required by [MS-RDPERP] 2022-06-29 11:41:45 +02:00
Adrian Perez de Castro
81e8e28062 Fix building with LibreSSL 2.7.0 or newer
With LibreSSL 2.7.0 (or newer versions) some more structs have made
opaque, which requires a few changes:

- BIO_meth_new() and related functions are now defined by LibreSSL, the
  versions from opensslcompat.{h,c} does not need to be used anymore.
- HMAC_CTX is now opaque, HMAC_CTX_new(), EVP_MD_CTX_new, and related
  functions should be used instead in winpr's hash.c.
2022-06-27 12:42:06 +02:00
akallabeth
9fee695ed0 Assert stream pool if duplicate entry is found 2022-06-27 11:21:24 +02:00
akallabeth
488a0d1edd Fixed streampool release 2022-06-27 11:21:24 +02:00
akallabeth
25c120d25d Fixed type mismatches and memory leaks 2022-06-27 11:21:24 +02:00
akallabeth
bc8b4ade1c reformatted 2022-06-23 08:48:39 +02:00
akallabeth
ec8550e87f Fix unwind backtrace warnings 2022-06-23 07:45:55 +02:00
fifthdegree
56d10c2d27 kerberos: don't get a tgt ticket for inbound creds 2022-06-21 10:27:17 +02:00
fifthdegree
8ac977e671 make sure existing ccache credentials are not expired 2022-06-21 10:27:17 +02:00
David Fort
a31574d359 kerberos: correctly detect missing credentials even with an empty cache 2022-06-21 10:27:17 +02:00
David Fort
90a2b9a10c Various fixes in negotiate.c 2022-06-21 10:27:17 +02:00
fifthdegree
b5ba6d135c retry on all errors from acquire_creds 2022-06-21 10:27:17 +02:00
fifthdegree
c51348a33b fixes 2022-06-21 10:27:17 +02:00
fifthdegree
e66b99f8dc deprecate old hash callback field 2022-06-21 10:27:17 +02:00
fifthdegree
6d3aa52496 set SAM file and hash callback on credential rather than context 2022-06-21 10:27:17 +02:00
fifthdegree
eeece1a027 server-side kerberos (and some fixes) 2022-06-21 10:27:17 +02:00
fifthdegree
8d9f990124 some more tweaks 2022-06-21 10:27:17 +02:00
fifthdegree
441fa01acb adjust ntlm unit test 2022-06-21 10:27:17 +02:00
fifthdegree
a359124339 some small fixes and changes 2022-06-21 10:27:17 +02:00
fifthdegree
1c012b09b8 implement proper SPNEGO negotiation 2022-06-21 10:27:17 +02:00
akallabeth
f25261e271 Unifiy string append functions 2022-06-17 08:41:46 +02:00
akallabeth
31708d8b20 Disable LTO on apple devices 2022-06-03 08:51:40 +02:00
akallabeth
1aacf504a1 Increase C standard to C11 2022-06-03 08:51:40 +02:00
akallabeth
a0ca2b4a6e Add LTO settings 2022-06-03 08:51:40 +02:00
akallabeth
3d65e5a138 Fix return of getlogin() 2022-06-02 13:57:09 +02:00
Marc-André Moreau
227aa6a55f Fix WinPR SSPI unit tests to always use SSPI function table 2022-06-01 15:16:12 +02:00
Marc-André Moreau
1d5c0be5ec Add settings to load a custom SSPI shared library module 2022-06-01 15:16:12 +02:00
David Fort
0a404d5728 fix a warning seen on the MacOS CI 2022-05-30 14:05:41 +02:00
akallabeth
65938708c0 Fixed WITH_PKCS11 option 2022-05-12 11:36:01 +02:00
akallabeth
4c452a96c4 Fixed broken #define guards 2022-05-12 11:36:01 +02:00
David Fort
77413f49b2 winpr: rework alignment functions
_align_XXX functions aren't widely available depending on the C runtime. That causes
problems with mingw where we can easily have some runtime mixes (which lead to mysterious
segfaults most of the time). This patch introduce winpr_aligned_XXX functions that will
either use the function available, or use an emulation layer.
2022-05-12 11:36:01 +02:00
David Fort
82092f6752 smartcard: add verbose output during listing 2022-05-12 11:36:01 +02:00
akallabeth
ca9247ddd9 Do not compile ncrypt_pkcs11 if CMake option is not set 2022-05-06 13:39:26 +02:00
David Fort
4ffd3e84b9 smartcard: take in account pkcs11-module in smartcard listing and print pkcs11 errors 2022-05-06 13:39:26 +02:00
David Fort
a612ca4ba2 winpr: fix unitary test when CreateProcess is CreateProcessW
As the second argument of CreateProcessW is modified to split with spaces and so
this can not be a const arg.
2022-05-05 13:11:18 +02:00
Armin Novak
03ed367fb9 Fixed broken USE_UNWIND check 2022-05-05 13:05:33 +02:00
Armin Novak
400fe6f796 Fixed argument mismatch 2022-05-03 11:48:20 +02:00
akallabeth
6ce3499e13
Settings getter tests (#7869)
* Added tests for freerdp_[static|dynamic]_collection_* functions

* Added settings unit test for clone functions

* Fix argument for winpr_RAND and winpr_RAND_pseudo

Using void* eliminates all assumptions of which type the buffer is.
This eliminates unnecessary warnings.
2022-05-02 11:39:38 +02:00
akallabeth
a62fe8a3e9 Enable unwind.h and dladdr as default backtrace implementation
* config option USE_UNWIND to enable/disable
2022-04-29 15:15:53 +02:00
akallabeth
f10da4552b default android to unwind 2022-04-29 14:27:44 +02:00
akallabeth
9330559d24 Defined and use _write 2022-04-29 14:27:44 +02:00
akallabeth
00b00ea521 Added unwind.h support 2022-04-29 14:27:44 +02:00
akallabeth
f146709eec Moved corkscrew backtrace to own file 2022-04-29 14:27:44 +02:00
akallabeth
3e62a05134 Moved windows backtrace to own file 2022-04-29 14:27:44 +02:00
akallabeth
0491f91327 Moved execinfo backtrace to own file 2022-04-29 14:27:44 +02:00
akallabeth
f8ada8984d Simplified CMake variable names 2022-04-29 14:27:44 +02:00
akallabeth
860f44f762 CMake check_include and struct cleanup
Move to WinPR what should be there.
2022-04-29 14:27:44 +02:00
akallabeth
340f9dd775 Fixed conditional warnings 2022-04-28 12:37:19 +02:00
akallabeth
d63817640f Fixed ArrayList_SetItem, return success 2022-04-28 12:37:19 +02:00