The lpnSize parameter for GetComputerNameEx specifies the total
size of the buffer (in characters).
However, the current code calculated the amount of bytes.
Since only GetComputerNameExA was used and because sizeof(CHAR) == 1
the result was correct but the math was wrong.
Credit goes to @byteboon
Depending on the windows target version (_WIN32_WINNT), the used
SDK and the build configuration the linker will see multiple
libraries exporting the same symbols.
To prevent ugly hacks (e.g. modifying cmake's default system
libraries or fragile library linking order chains) we prefix
these functions with "winpr_" and create corresponding defines
to keep the current api names.
On input, the lpnSize [in, out] parameter for GetComputerNameEx()
specifies the total size of the buffer (in characters).
Several functions in ntlm.c were off by one which caused ntlm to fail
if the netbios hostname's strlen was exactly MAX_COMPUTERNAME_LENGTH.
PathMakePathA:
- This function had an endless loop if no native delimiter was in the string
- Use SHCreateDirectoryExA on Windows
- Replaced old code with a new implementation
TestWLog:
- Windows has no "/tmp" by default
- Use GetKnownPath(KNOWN_PATH_TEMP) for the WLog "outputfilepath"
- Use correct SetLastError values in GetModuleFileName
- Fix wrong return codes in GetModuleFileName
- Build the TestLibraryA/TestLibraryB libraries always shared and
put them in the test output directory
- TestLibraryGetModuleFileName always returned success
- Improve TestLibraryGetModuleFileName to also check last error values
and insufficient buffer sizes
- Change TestLibraryGetProcAddress and TestLibraryLoadLibrary to load
the TestLibrary from the test executable's directory
TestNtCreateFile, TestPipeCreateNamedPipeOverlapped
- These tests are currently only expected to succeed on _WIN32
- Also reflect the reverse meaning of this fact in the return values
TestSynchWaitableTimer, TestSynchWaitableTimerAPC:
- These tests are currently expected to fail on __APPLE__
- Also reflect the reverse meaning of this fact in the return values
This logic makes sure that we don't forget to fix the tests if the
corresponding WinPR implementations are fixed.
TestLibrary:
- TestLibraryA and TestLibraryB must always get built as shared libraries
Let the compiler know that we're comparing a volatile value.
Otherwise the compiler might nuke the comparison operation
and produce code that will spin endlessly.
The SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY flag caused this test
to run extremely long if the system has very few processors.
Although this is expected (thread starvation) this will cause a
intolerably long execution time for automated tests.
Changed the number of threads to be calculated dyamically based
on the number of processors.
Also do proper cleanup to prevent memory leaks.
The current experimental/incomplete WinPR timer queue implementation
has several race conditions.
This commit fixes a segfault caused by not unklinking freed timers
from the timer queue timers list.
pool:
- the winpr implementation fallback was not used on older windows editions
- drop useless and conflicting TP_CALLBACK_ENVIRON_V3
- fix race conditions by using use proper one-time initialization
- on win32 WinPR tried to load several pool/callback_environment functions
from kernel32.dll but since these are defined as inline functions in the
windows headers, no windows edition has ever exported them in any dll.
- removed callback_environment.c and added corresponding static inline
function to pool.h
- fix segfault in TestPoolWork: CloseThreadpoolWork() must not be called
if there is a cleanup group associated with the work object since calling
CloseThreadpoolCleanupGroupMember() already releases the work object
sync:
- The windows headers incorrectly define InitializeCriticalEx support if
_WIN32_WINNT >= 0x0403 instead of >= 0x0600 (Vista)
- created a compatible define to deal with this issue
On some operating systems sched_yield is a stub returning returning -1.
In that case use usleep which should at least trigger a context switch
if any thread is waiting.
Half of the tests expects strings in little endian byte order, half of
the tests expects byte order based on a current architecture, so it
obviously can't work on big endian machines. Wide char strings use
always little endian encoding since commit f722dc5. Use only strings
in little endian to make the tests endian-independent.
Since the current winpr implementation for overlapped operations is
incomplete and buggy, all affected functions will now fail if they are
called with a set FILE_FLAG_OVERLAPPED flag or a non-null pointer to
a OVERLAPPED structure.
winpr/nt:
- use proper one-time initialization on win32
- fix TestNtCreateFile
- fix broken/incomplete _RtlAnsiStringToUnicodeString
- unimplemented functions return appropriate error codes
winpr/pipe:
- improved TestPipeCreateNamedPipe
- rewrite the completely broken TestPipeCreateNamedPipeOverlapped test
rdtk:
- improve test and don't blindly return success
winpr/synch:
- fix race condition in TestSynchTimerQueue
winpr/ssspi:
- fix TestEnumerateSecurityPackages printf output
- fix TestQuerySecurityPackageInfo printf output
winpr/environment:
- fix GetEnvironmentStrings printf output
winpr/comm:
- unimplemented functions return appropriate error codes
winpr/io:
- unimplemented functions return appropriate error codes
winpr/thread:
- implement SwitchToThread() via sched_yield()
This patch fixes NTLM authentication to work properly on a big endian
machines. Freerdp exited with the following error without recent commits:
[09:50:20:914] [13821:13822] [ERROR][com.freerdp.core.transport] - BIO_read returned an error: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error
[09:50:20:914] [13821:13822] [ERROR][com.freerdp.core] - freerdp_set_last_error ERRCONNECT_CONNECT_TRANSPORT_FAILED [0x2000D]
[09:50:20:914] [13821:13822] [ERROR][com.freerdp.client.x11] - Freerdp connect error exit status 1
https://github.com/FreeRDP/FreeRDP/issues/2520
Data in ntlm_av_pair_list are accessed directly, which doesn't work on
big endian machines currently. The recieved data are stored as little
endian. Use conversion macros from endian.h to load and store the data
properly.
https://github.com/FreeRDP/FreeRDP/issues/2520
All WCHAR strings are stored as little endian after commit 12dfc5e9,
therefor CharUpperBuffW and CharLowerBuffW have to be changed appropriately
in order to fix NTLM authentication.
https://github.com/FreeRDP/FreeRDP/issues/2520
Unicode conversions doesn't work on big endian machines currently.
The strings are stored as little endian. Use conversion macros from
endian.h to load and store the data properly.
Let's use wide char strings always as little endian. It seems that
Windows API also always expects data to be little endian, so it
makes sense to require wide char strings as little endian also.
The patches fixes transformations between UTF8 and UTF16 only, which are
used by freerdp. UTF32 transformations are not used by freerdp.
https://github.com/FreeRDP/FreeRDP/issues/2520